A large model-based vectorized Chinese character pattern generation method
By extracting stroke features of Chinese characters using a specific convolutional neural network and the Transformer large language model, vectorized Chinese characters are generated according to stroke order. This solves the problems of poor generation quality and low efficiency in existing technologies, and achieves efficient generation of semantically consistent Chinese text content.
Patent Information
- Application Number
- CN202511536703.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-27
- Publication Date
- 2026-02-10
- Estimated Expiration
- 2045-10-27
AI Technical Summary
Existing methods for generating vectorized Chinese characters cannot generate semantically rich vectorized sentences, and the generation quality is poor. They also cannot effectively utilize the stroke order information of Chinese characters, resulting in low efficiency and poor character quality.
The stroke features of Chinese characters are extracted by a specific convolutional neural network to generate the encoding of a single vectorized stroke. The Transformer large language model is then used to generate semantically rich Chinese word phrases or verses according to the stroke order. Finally, Bézier curves are used to reconstruct the vectorized graphics.
It enables the efficient generation of vectorized text content of Chinese character phrases and poems that conform to language habits, improving the efficiency and quality of Chinese character generation. It can complete missing character shapes and is suitable for artistic character generation and Chinese font auxiliary design.
Smart Images

Figure CN121010668B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The application belongs to the field of computer vision and vectorized image generation, and particularly relates to a vectorized Chinese character pattern generation method based on a large model. BACKGROUND
[0002] A vectorized image is a graphical expression based on mathematical formulas and geometric elements, usually using points, lines, curves, and polygons, and is defined by mathematical equations such as Bezier curves. It is not limited by resolution and can be infinitely scaled without loss of quality. Vectorized images store graphical elements in units of objects rather than pixel grids, and maintain each element as an independent editable state, unaffected by pixel overlay and occlusion factors. As an important paradigm of digital graphics, vectorized images maintain mathematical purity while continuously expanding application boundaries. With the increasing development of display technology, they have been widely used today. Their resolution-independent core characteristics make them highly popular in data, design, and intelligent interaction, and provide good support for cross-platform display technology.
[0003] Vectorized glyphs are a representation of character graphics described by vectorized images, and are the mainstream font storage form of modern digital fonts. Compared with rasterized glyph images, they can be scaled arbitrarily without producing jaggies in different display scenarios, and can be displayed without distortion on different screens and at different resolutions using the same method. Because vectorized glyphs are parameterized by mathematical formulas, they can easily support interpolation generation of visual variants such as font weight and width, and are widely used in modern printing and intelligent interactive display. Due to the independent editable nature of vectorized images, vectorized glyphs make font design more convenient, allowing text to have diverse styles while maintaining visual aesthetics and integrating deeply into various levels of human-computer interaction.
[0004] Chinese characters have formed a unique writing style through a long evolution process. Due to the complexity of their character images, they are usually stored and represented using vectorized glyphs. Vectorized glyphs of Chinese characters are of great significance in the fields of cultural heritage protection, cross-platform digital display, and glyph design. Inscriptions, epigraphs, and ancient books, which have been eroded by the passage of time, have unique writing styles. It is often difficult to obtain a large amount of complete glyph data for these characters. After vectorization, they can be conveniently recorded, saved, and disseminated, and can be combined with AI technology to infer missing character content, helping to restore the appearance of ancient characters and transfer their style characteristics to all Chinese characters for application in modern character display.
[0005] With the development of computer graphics, generative models have achieved varying degrees of success in vectorized character generation tasks. Currently, vectorized Chinese character generation methods can be classified into three categories: the first category involves manually designing all vectorized character images; the second category is based on traditional algorithms for automatic conversion from bitmap to vector graphics; and the third category is based on deep learning for vectorized character generation.
[0006] The first type of method, which involves purely manual design of vectorized glyph images for all Chinese characters, requires outlining the entire stroke of each target character in the character set. Vector editors such as Glyphs, FontLab, and FontForge are used to manually edit the character outlines. This process begins with scanning a high-quality reference image, followed by manually determining the character frame, center line, and stroke direction, marking the start and end points, turning points, and curve feature points of each stroke, and finally refining the character outline. This method is extremely labor-intensive, requiring an average of 30-100 control points per character. The process is tedious and time-consuming, resulting in very low productivity. Furthermore, due to its heavy reliance on manual labor, the quality of the annotations cannot be guaranteed.
[0007] The second type of automatic bitmap-to-vector conversion method, based on traditional algorithms, requires using existing bitmap images of Chinese characters. It involves binarization and noise removal, then extracting and distinguishing the outer contour and filling the inner contour of the character image using methods such as Canny and Moore-Neighbor. Finally, the extracted contour curves are optimized using algorithms such as Douglas-Peucker and Potrace to obtain vectorized glyphs. This method is fundamentally about converting existing glyph images into vectorized glyphs. Although the quality of the extracted glyph contours varies depending on the algorithm used, it essentially does not generate a new font style, nor can it generate a vectorized image without a bitmap reference character.
[0008] The third category of vectorized character generation methods, based on deep learning, uses neural network models to convert Chinese character bitmaps into mathematically described vector outlines. Typically, convolutional neural networks are used to extract multi-level features of the character shapes, and then recurrent neural networks are used to generate ordered sequences of Bézier curve control points. Adversarial training and attention mechanisms may be employed to ensure overall consistency. Deep learning-based methods have also shown good performance in generating character samples without a target, and the amount of character bitmap data required for basic training is relatively small. However, current deep learning methods lack consideration for the semantics of Chinese characters, and there is still significant room for improvement in the uniformity of character shapes and the style between strokes. Furthermore, existing research can only generate vectorized single characters, not vectorized text with coherent semantics.
[0009] Main existing technologies:
[0010] CN120563664A proposes a deep learning-based method for generating Chinese character glyphs. Its core principle is to achieve efficient and diverse glyph generation through multi-feature fusion and loss optimization. The system comprises five modules: image encoding, feature extraction, loss function construction, weighted optimization, and glyph generation, forming an end-to-end generation process. The input image of the Chinese character to be processed is converted into a sequence of Chinese character images by an encoder, preserving spatial structure and positional information (achieved through positional encoding). Utilizing a dual-feature extraction mechanism, it captures the visual texture, stroke shape, and stylistic details of the Chinese characters in terms of style, and semantically mines the meaning and information of the characters in context, ensuring that the generated result conforms to semantic logic. Although the CN120563664A method encodes the image into a sequence and preserves positional information, its "parallel encoding" and "segmentation strategy" cannot achieve high-quality generation of Chinese characters for images of different resolutions and fonts. The generated images are rasterized images with no specified resolution, making free scaling impossible in practical applications. At the semantic level, because it only uses single-character images for training, it cannot learn coherent and effective semantics.
[0011] CN120543697A employs a dual-branch feature extraction and conditional diffusion generation architecture. It receives two images from the user—a target stroke-style character image and a target skeleton character image. A neural network encoder extracts multi-scale skeleton features, which are then input into different layers of a U-Net. A VGG11 encoder extracts style features, which are then projected onto the intermediate feature space of the diffusion model via a multilayer perceptron (MLP). The diffusion model, centered on U-Net, incorporates skeleton and stroke features as conditional guidance at each step of the denoising process, gradually generating the target new font image. CN120543697A requires a large amount of computation (typically tens or even hundreds of steps) to generate a single high-quality image. This patented method, in addition, requires parallel operation of a skeleton encoder (CNN) and a stroke-style encoder (based on VGG11) to extract multi-scale conditional features and dynamically inject these features into different layers of the U-Net. This results in a massive number of parameters and slow inference speed, making it difficult to meet the needs of applications requiring real-time or near-real-time font generation. The only way for users to control the generated results is to specify two complete reference images (one providing the skeleton and the other providing the stroke style). This method lacks finer-grained control, and the generated results are rasterized images, making precise editing of Chinese characters impossible. This method may face challenges when handling fonts with extremely complex structures or extremely freehand styles (such as cursive script). Skeleton extraction algorithms (binarization, skeletonization) may be very sensitive to low-quality or artistic inputs, and the extracted skeletons may be inaccurate or broken. Diffusion models may produce adhesion, breaks, or unreasonable smooth transitions when generating extremely long, continuous strokes, making it difficult to maintain the unique charm and continuity of certain calligraphic styles.
[0012] CN120220168A effectively addresses the issues of detail loss, style uniformity, and reliance on paired data in traditional font generation models by introducing a Transformer structure and a perceptual loss mechanism. It can generate Chinese character images with clear structure, diverse styles, and high visual quality. The system employs a Generative Adversarial Network (GAN)-based architecture, utilizing a U-shaped generator to extract spatial features from Chinese character images and perform style fusion to generate Chinese character images of the target style. A discriminator judges the authenticity of the generated images, ensuring the visual credibility of the output. Random noise is mapped to style codes, supporting multiple style generation. Style features are extracted from reference images to provide the generator with target style vectors. CN120220168A introduces Channel Transformer (CBT) and Spatial Transformer (SBT) structures into the generator and integrates multiple linear projection layers, depthwise convolution, and pointwise convolution operations. The computational complexity of the Transformer's self-attention mechanism increases quadratically with sequence length, leading to significant computational overhead and memory consumption when processing high-resolution Chinese character images, thus slowing down model training and inference. The style encoder uses the first eight layers of VGG11 (pre-trained on ImageNet), and its low-level features are mainly optimized for natural images. This differs from the structured features of Chinese character strokes and may not optimally capture the unique style of calligraphy (such as flying white strokes and pauses). The generated images are rasterized, which is detrimental to subsequent image editing and applications. It only generates single characters and cannot consider the semantics of Chinese characters.
[0013] CN111666739B optimizes and improves the fitted polygons and Bezier curve segments in the Potrace algorithm, performs high-quality dotting on the font curve outline, and then vectorizes the Chinese font image to generate an svg vector file. The fonts produced by this method are realistic and high-quality results, showing advantages over other methods in terms of visual appearance. Moreover, the curve lines of the outline have high smoothness, can accurately capture the overall features and local details, and have high precision. At the same time, this method not only reduces the number of path points but also retains the key style details of the outline. The method of CN111666739B is based on binarization. If there is anti-aliasing, gray-scale transition or slight blur in the original font design image (especially at the stroke intersections and turns), information loss or noise will be introduced during the binarization process. Its denoising ability is limited, and poor-quality input will lead to error accumulation in the subsequent path decomposition and fitting links. The algorithm "randomly selects a pair of adjacent pixels with different colors" as the starting point and relies on the rule of "keeping the left side black and the right side white" for path expansion. This greedy and locally optimal path search strategy is very likely to produce non-unique or non-optimal path decomposition results in complex glyph structures (such as Chinese characters containing a large number of closed structures such as "mouth" and "field"), and may miss more concise or more visually recognizable path schemes. This method can only convert rasterized images into vectorized images and cannot complete or expand the input vectorized characters, etc. The corresponding target Chinese characters will be missing when the input data is incomplete.
[0014] Existing methods all consider vectorized Chinese character images in the same way as ordinary images such as pictures and photos, ignoring the unique properties of Chinese characters themselves. The stroke order information naturally carried by Chinese characters enables them to be naturally modeled as a series of stroke sequences composed in a specific order, and this information has not been effectively utilized in the long-term process of generating vectorized Chinese characters. In addition, the vectorized Chinese characters generated by existing methods have low efficiency, poor glyph quality, and are limited to single character generation. Summary of the Invention
[0015] To address the problems of existing vectorized Chinese character generation technologies, such as single-character generation, inability to generate semantically rich vectorized sentences, and poor generation quality, this invention proposes a vectorized Chinese character generation method. This method comprises two key steps: First, this invention proposes to extract features from the strokes of vectorized Chinese characters using a specific convolutional neural network, thereby generating a special encoding for each individual vectorized stroke. This encoding process effectively extracts and compresses stroke information. Then, the encoded strokes are arranged into a sequence according to the stroke order of Chinese characters. This sequence is trained using a large language model with a Transformer structure, and semantically rich single-character or multi-character vectorized results are generated by predicting the encoding of the next stroke. This invention is trained on a small number of vectorized Chinese character samples and can generate high-quality vectorized text content such as Chinese phrases and poems that conform to language habits and have correct semantics.
[0016] Technical solution
[0017] A method for generating vectorized Chinese character graphics based on a large model includes the following steps:
[0018] Step 1: Data preprocessing;
[0019] The vectorized Chinese characters used for model training first need to be decomposed into multiple independent stroke outlines according to their character structure and writing norms, ensuring the writing order between strokes, converting the stroke control points into cubic Bézier curve format, and then normalizing the coordinates.
[0020] Step 2: Stroke feature extraction;
[0021] After the initial stroke data is restructured, it is fed into a multi-layer convolutional neural network (CNN) for feature extraction. The 8×dim feature map extracted by the multi-layer convolutional neural network is split along the spatial dimension to obtain 8 independent 1×dim feature vectors, where dim represents the preset feature dimension.
[0022] Step 3: Discretize and encode the feature vectors;
[0023] Each 1×dim continuous feature vector is mapped to a discrete code to achieve spatial transformation and reduce modeling complexity;
[0024] Step 4: Arrange the pens in sequence;
[0025] The vectorized text content is processed by breaking down each character into independent strokes and arranging them strictly according to their stroke order to form a global stroke sequence. Each stroke is converted into a discrete code through stroke feature extraction and discretization encoding. The discrete codes of all the strokes are then concatenated in the stroke order of the characters they belong to to construct a complete long sequence (discrete code sequence).
[0026] Step 5: Feature encoding prediction;
[0027] The discrete encoded sequence arranged in stroke order in step four is normalized; the processed sequence is then input into a large language model based on the Transformer architecture for modeling and prediction.
[0028] Step Six: Encode and Restore Features;
[0029] The feature encoding prediction generated in step five is restored to a stroke feature representation in continuous space for subsequent vectorized image reconstruction or output.
[0030] Step 7: Stroke Restoration
[0031] The 8×dim feature matrix obtained in step six is reversed and restored into individual strokes that can be analyzed by vector graphics software using a deep neural network.
[0032] Beneficial effects
[0033] This method combines Chinese character stroke order information. In addition to completing the strokes of Chinese characters to generate complete vectorized images, it can also generate continuous and semantically rich Chinese character vectorized text content by predicting the strokes of the next character. It can complete missing character shapes when the font library is incomplete and realize creative vectorized Chinese character text generation. It can contribute to the fields of artistic character generation, Chinese character font auxiliary design, and advertising text design, reduce manual costs, and achieve efficient generation. Attached Figure Description
[0034] Figure 1 This is a schematic diagram of the processing flow of the method of the present invention;
[0035] Figure 2 This is a schematic diagram of the overall processing structure according to an embodiment of the present invention;
[0036] Figure 3 This is a schematic diagram showing the result of stroke decomposition during vectorized Chinese character preprocessing in an embodiment of the present invention.
[0037] Figure 4 This is a schematic diagram illustrating the multi-character data processing method according to an embodiment of the present invention;
[0038] Figure 5This is a schematic diagram illustrating the effect of generating words and sentences with a small number of stroke inputs in an embodiment of the present invention.
[0039] Figure 6 This is a schematic diagram illustrating the stroke generation process for completing a single character according to an embodiment of the present invention;
[0040] Figure 7 A comparison chart showing the generation effects of different existing vector Chinese character generation methods;
[0041] Figure 8 A quality evaluation result graph is generated for an embodiment of the present invention. Detailed Implementation
[0042] The technical solution provided in this application will be further described below with reference to specific embodiments and accompanying drawings. The advantages and features of this application will become clearer from the following description.
[0043] A method for generating vectorized Chinese character graphics based on a large model includes the following steps: (See diagram for specific processing steps) Figure 1 The overall processing structure diagram is as follows: Figure 2 )
[0044] Step 1: Data Preprocessing
[0045] The vectorized Chinese characters used for model training first need to be decomposed into multiple independent stroke outlines according to their character structure and writing norms, ensuring the writing order between strokes, converting the stroke control points into cubic Bézier curve format, and then normalizing the coordinates.
[0046] Each stroke is represented by a closed vectorized curve, ensuring that the length of its Bézier curve command sequence does not exceed 64 to guarantee data regularity and computational efficiency in subsequent processing. During the decomposition process, the standard stroke order of Chinese characters must be strictly followed, preserving the writing sequence between each stroke. This sequence information will serve as an important temporal context for subsequent stroke relationship modeling and dynamic feature expression. To further unify the data representation, the computational characteristics of Bézier curves are utilized to uniformly convert the control point representations of all strokes into a cubic Bézier curve format. Each curve segment is described using six parameters (x1, y1, x2, y2, x3, y3), where (x1, y1), (x2, y2), and (x3, y3) are the coordinates of the three control points of the Bézier curve, thereby achieving data structure standardization and normalization.
[0047] Based on this, the coordinates within each stroke are normalized to eliminate scale differences caused by character size, translation, etc., while preserving the relative positional relationships and geometric structure within the strokes. Normalized data not only improves the stability of model training but also enhances the system's generalization ability to different fonts and writing styles.
[0048] Step 2: Stroke Feature Extraction
[0049] First, the initial input stroke data (64×6) is structurally restructured, decomposing the 64 dimensions into two 8×8 dimensions, thus transforming it into an 8×8×6 three-dimensional data matrix to meet the input requirements of the subsequent convolutional neural network. Then, the restructured data is input into a multi-layer convolutional neural network (CNN) for feature extraction. Finally, the 8×dim feature map extracted by the multi-layer convolutional neural network is decomposed along the spatial dimensions to obtain eight independent 1×dim feature vectors, where dim represents the preset feature dimension.
[0050] The structural reorganization process not only maintains the integrity of the original stroke information, but also provides spatial structural support for subsequent feature learning.
[0051] The multi-layer convolutional neural network consists of alternating convolutional layers, activation function layers, and pooling layers, enabling it to progressively capture multi-level features from local details to global structure in stroke data. Small-sized convolutional kernels are used in the convolutional operations to enhance the perception of subtle changes in strokes, and non-linear activation functions are employed to improve the model's expressive power.
[0052] After multiple cascaded convolution operations, the feature map is gradually compressed and abstracted, ultimately outputting a feature map of size 8×dim, where dim represents the preset feature dimension. This feature map contains high-level semantic information about the strokes.
[0053] Each 1×dim feature vector corresponds to a segment or region in the original stroke, representing the depth feature representation of that local region (segment or region). These feature vectors can be used individually for subsequent stroke analysis and recognition tasks, or as a whole for sequence modeling.
[0054] Step 3: Feature Vector Discretization Encoding
[0055] The feature vectors extracted in step two are in a continuous vector space, while subsequent sequence prediction tasks (such as stroke generation or Chinese character reconstruction) need to be performed in a discrete symbol space. Therefore, each 1×dim continuous feature vector needs to be mapped to a discrete code to achieve spatial transformation and reduce modeling complexity.
[0056] The specific process is as follows:
[0057] First, construct a learnable discrete codebook with a size of K×dim, where K represents the total number of preset discrete codes and dim is the dimension of the feature vector.
[0058] The discrete codebase is constructed through uniform initialization or clustering based on training data, where each row represents a cluster center vector, i.e., a discrete semantic unit. These units are uniformly distributed in the vector space, collectively covering a continuous feature space.
[0059] Subsequently, for each continuous feature vector to be encoded, the nearest neighbor search strategy is used to find the cluster center vector with the smallest Euclidean distance in the encoding sample.
[0060] Specifically, the distance between the feature vector and all K vectors in the encoding is calculated, the nearest neighbor index k is selected, and the discrete vector corresponding to the index is used as an approximate representation of the original continuous vector.
[0061] Finally, the retrieved discrete vector (size 1×dim) is used as the input to the subsequent sequence prediction model, and the index k can also be directly used as the discretization symbol of the feature to participate in sequence modeling.
[0062] This process not only achieves an efficient conversion from continuous features to discrete symbols, but also helps the model handle structured outputs and generation tasks.
[0063] Step 4: Combining the pen in sequence
[0064] To construct training samples suitable for sequence prediction tasks, it is necessary to process the vectorized text content, such as complete Chinese characters, phrases, or poems. First, according to standard writing conventions, each character is broken down into individual strokes and arranged strictly according to their stroke order to form a global stroke sequence.
[0065] Each stroke is processed through the aforementioned steps (stroke feature extraction and discretization encoding) and converted into 8 discrete codes, which together represent the deep semantic and structural features of the stroke. Therefore, each stroke can be represented as a subsequence containing 8 discrete symbols.
[0066] The discrete codes of all the above strokes are concatenated sequentially according to the stroke order of the characters they belong to, constructing a complete long sequence of length n (the total number of discrete codes). This sequence, in the form of discrete symbols, completely preserves the stroke structure, writing order, and semantic information of the original characters. It can be used as input to generative models (such as Transformer, RNN, or autoregressive models) for training stroke-level or character-level sequence prediction tasks, such as: generating Chinese characters during writing, automatic completion or error correction of vectorized text, and the transfer and synthesis of stroke order and stroke style.
[0067] This method represents Chinese character writing as a structured discrete sequence, which not only preserves the visual and topological characteristics of strokes, but also meets the requirements of autoregressive generative modeling, and is applicable to a variety of intelligent writing generation and processing scenarios.
[0068] Step 5: Feature Encoding Prediction
[0069] In this step, a large language model (LLM) based on the Transformer architecture is used to model and predict the discrete encoded sequences generated in the previous steps.
[0070] First, the discrete encoded sequences arranged in stroke order are normalized. Specifically, a start symbol (BOS) is added to the beginning of the sequence, an end symbol (EOS) is added to the end, and padding symbols (PAD) are used to align sequences of different lengths to meet the requirements of batch training.
[0071] The processed sequence is then fed into the Transformer model for training. The model predicts the next discrete code in an autoregressive manner, conditioned on the preceding code. Specifically, at each time step, the model predicts the value of the next code based on all current and previous codes (i.e., known sequence portions). This process iterates until the model outputs an EOS symbol, indicating that the current sequence prediction is complete.
[0072] During training, the data is divided into several batches for supervised training based on hardware resource configuration, and the model parameters are optimized by gradient descent to minimize the cross-entropy loss between the predicted and the true values.
[0073] This modeling approach enables Transformer to capture the complex dependencies and stroke order semantics between stroke codes, thus enabling it to generate coherent and structurally sound vectorized stroke sequences. It can be widely applied to scenarios such as Chinese character generation, stroke order inference, and calligraphy synthesis.
[0074] Step Six: Encoding and Reconstructing Features
[0075] After generating a complete discrete coding sequence through feature coding prediction in step five, it needs to be restored to a stroke feature representation in continuous space for subsequent vectorized image reconstruction or output.
[0076] Specifically as follows:
[0077] First, the predicted encoded sequence is post-processed to remove special control symbols (such as start symbol BOS, end symbol EOS, and padding symbol PAD), retaining only the effective discrete codes representing the semantics of strokes.
[0078] Subsequently, the cleaned discrete encoded sequences are grouped sequentially, with eight codes forming a group, and each group corresponding to the semantic representation of a complete stroke. This grouping strategy is consistent with the discretization process in step three, ensuring that the correspondence between codes and strokes is correctly reconstructed.
[0079] Based on the discrete encoding template constructed in step three, the eight discrete codes in each group are mapped back to their corresponding continuous feature vectors. Specifically, according to the index value k of each discrete code, the corresponding 1×dim-dimensional vector is retrieved from the encoding template.
[0080] Finally, the eight retrieved feature vectors are combined in sequence to reconstruct an 8×dim dimensional feature matrix, which represents the high-level semantic features of a stroke.
[0081] Step 7: Stroke Restoration
[0082] This step uses a deep neural network to reverse-engineer the 8×dim feature matrix into executable SVG vector graphics instructions. It consists of three sub-steps: feature decoding and parameter reconstruction, parameter post-processing and instruction generation, and SVG path construction.
[0083] The feature decoding and parameter reconstruction methods are as follows:
[0084] The deep neural network described uses a transposed convolutional neural network with a structure symmetric to the CNN in step two. This network progressively upsamples the 8×dim feature matrix to reconstruct a 64×6 original parameter matrix. It restores the spatial dimension through multiple deconvolution operations and retains high-frequency details with skip connections, ultimately outputting Bézier curve parameters of the same dimension as the input data.
[0085] The parameter post-processing and instruction generation methods are as follows:
[0086] The reconstructed 64×6 matrix is processed as follows: rows filled with all zeros are filtered out, and valid control point data are retained; each group of 6 parameters (corresponding to the coordinates of two control points and one endpoint) is converted into standard SVG cubic Bézier curve instructions (C commands); the control point coordinates are inversely normalized according to the scaling factor during coordinate normalization.
[0087] The SVG path is constructed as follows:
[0088] The processed Bézier instructions are concatenated according to the following rules: the starting point is positioned using the M instruction, consecutive Bézier segments are connected using the C instruction, and the closed path is appended with the Z instruction. This ultimately generates an SVG path string conforming to the W3C standard, forming a single stroke that can be parsed by any vector graphics software.
[0089] Example
[0090] The specific process of the vectorized Chinese character generation method of the present invention includes data preprocessing, stroke feature extraction, feature vector discretization encoding, stroke sequence combination, feature encoding prediction, encoding to restore features, and stroke restoration.
[0091] 1. Data collection and preprocessing process
[0092] Collecting vectorized data of Chinese characters: All vectorized data for Chinese characters is constructed using Bézier curve commands. The image of a vectorized Chinese character must be contour data (i.e., describing the outer contour of the character using closed Bézier curves, leaving the interior empty), because only the outer contour data can reveal the details of the writing style of Chinese characters. (e.g.) Figure 3 )
[0093] Chinese character stroke decomposition: A significant portion of the collected vectorized Chinese character data consists of the complete outline of the entire character, without individual line descriptions for each stroke. However, this invention requires data with individual stroke vector instructions. Therefore, it is necessary to decompose the strokes of each Chinese character. Due to the characteristics of Chinese character writing, different strokes may overlap, but it is essential to ensure that each stroke is an independent closed Bézier curve. Following the SVG vectorized image saving method, the Bézier curve corresponding to each stroke is stored as a path label, and the path labels are arranged according to the stroke order of Chinese character writing.
[0094] Format-aligned data: Since the collected vectorized stroke instructions only follow Bézier curve rules and are not format-aligned data, they cannot be directly used for training. Therefore, all Bézier curve instructions need to be converted into cubic Bézier curves (cubic Bézier curves can fully express the content of linear and quadratic Bézier curves). For semantic unit data with multiple characters, such as phrases, idioms, and poems, they are first arranged according to the order of the characters, then the stroke units of each character are arranged according to the stroke order, and the parameters are converted into cubic Bézier curves for storage.
[0095] For multi-character semantic units such as phrases, idioms, and verses, they must first be structurally organized according to their character order, forming a three-level hierarchical system of "text-character-stroke". (e.g.) Figure 4 Each Chinese character strictly adheres to the national standard stroke order, breaking it down into independent strokes and arranging them chronologically to ensure the integrity of the writing logic and structure. All strokes are uniformly represented as closed cubic Bézier curves, with each curve segment described by six parameters and their coordinates normalized to eliminate scale and translation differences, thus preserving their essential geometric features. The processed data is persistently stored in a structured format, including stroke sequence numbers, parameter matrices, and metadata. A triple quality control mechanism—visual rendering verification, mathematical continuity checks, and stroke order semantic verification—ensures data reliability and standardization. This process not only provides high-quality input for subsequent feature extraction and sequence prediction but also possesses multi-font style compatibility and data augmentation capabilities, laying a solid foundation for the model's generalization ability.
[0096] 2. Encoding and Decoding Model Training Process
[0097] The purpose of this process is to The Bézier curve data matrix is encoded as discretized numerical values, and the initial values can be restored from the discretized values. The Bézier curve data matrix is used to reconstruct the vectorized image.
[0098] First, the input data needs to be normalized, which means scaling all values down to between 0 and 1. Normalization can accelerate model convergence, make the contour lines of the loss function closer to the original, and allow gradient descent to find the target value more directly and quickly. Normalized data can help the model find better solutions, thereby improving accuracy, and can also stabilize the input values of the activation function within a sensitive range of large gradients, thus avoiding the gradient vanishing problem caused by gradients approaching zero.
[0099] To better extract features from vector graphics data, both the encoding and decoding models are implemented using convolutional neural networks. The input to the encoding model is... Given a Bézier curve data matrix, let dim=16, and the output will be... Feature vectors, discrete encoding is The uniform probability distribution matrix is the input to the decoding model. The feature vector, the output is The data matrix.
[0100] Discrete Codebook: Let K=30000, the codebook is of size... The matrix is initialized using a uniform probability distribution, and each time the dimension is... The distance between the feature vector and K vectors in the encoding sample is calculated. The vector with the closest distance is selected as the discretization target vector, and the index of this vector is used as the discretization result. In this way, the discretization encoding of each feature vector is completed. Essentially, the continuous space is divided into K cluster centers in a uniform distribution. The nearest neighbor method is used to find the cluster center k that is closest to this feature vector, and the vector of the cluster center is used to replace the original feature vector to classify the feature vector, thereby quantifying continuous values and obtaining discrete values.
[0101] By jointly training the encoding and decoding models, it is possible to discretize and encode strokes, and then reconstruct the initial strokes from the discretized encoding. (e.g.) Figure 5 )
[0102] 3. Training process of the encoding prediction model
[0103] During model initialization, the pre-trained model deepseek-1.3b with a near-decoder structure was selected as the backbone network. Its core components, such as embedding layers, attention mechanisms, and feedforward networks, were retained, and the hidden layer dimensions remained consistent with the original model (typically 768 / 1024 / 1280, etc.). Pre-trained weights were used as initial values for parameter loading. The original vocabulary mapping layer was replaced with an output layer adapted to the stroke encoding scale, with its dimension consistent with the discrete encoding size K. To support long sequence processing, the positional encoding was extended (from 2K in the original model to 8K), and a sliding window attention mechanism was adopted to reduce computational complexity.
[0104] The training data is based on previously processed discrete encoded sequences. Each batch of data contains an input sequence, an attention mask, and a label sequence. The input sequence begins with the <BOS> symbol, followed by stroke codes and ends with <EOS>, with insufficient parts padded with <PAD> to a fixed length. The attention mask identifies the valid data locations. The label sequence corresponds to the target code to be predicted. The loss is calculated using masked cross-entropy loss, calculating the loss value only for non-padded locations to ensure the effectiveness and accuracy of training.
[0105] The fine-tuning process employs a progressive strategy implemented in three phases: first, the backbone network is frozen, and only the output mapping layers are trained (1-2 rounds); then, the last 3 layers are unfrozen and trained (2-3 rounds); finally, the entire network is fine-tuned (4-8 rounds). The AdamW optimizer is used for optimization, with the backbone network learning rate set to 5e-5 and the newly added output layer learning rate set to 1e-4, along with a weight decay coefficient of 0.01. Learning rate scheduling uses a combination of linear warm-up and cosine decay strategies: the first 3% of training steps increase the learning rate from 0 to the target rate, and the subsequent 97% of steps slowly decay to 10% of the maximum learning rate.
[0106] Several stabilization techniques were implemented during training: the gradient pruning threshold was set to 1.0, and both the attention dropout rate and the feedforward network dropout rate were 0.1, effectively preventing overfitting. Dynamic batch processing grouped sequences based on their length, with a maximum sequence length set to 2048, reducing padding costs while supporting long text generation. Training monitoring employed a triple mechanism of smoothed cross-entropy loss, validation perplexity, and visualization of generation quality. Perplexity was calculated on the retained validation set every 500 steps, and stroke sequences were sampled and generated after each training round for visual inspection.
[0107] The early stopping mechanism is triggered when the perplexity fails to improve after three consecutive rounds of validation. The system automatically saves both the best and final model checkpoints and can roll back to the optimal performance state. The performance validation phase employs a combined quantitative and qualitative evaluation system: calculating quantitative indicators such as encoding prediction accuracy, stroke generation success rate, and geometric similarity (Hausdorff distance).
[0108] This training scheme fully leverages the sequence modeling advantages of pre-trained models. Through a carefully designed fine-tuning strategy, the model adapts to the stroke encoding sequence generation task in a short time, ensuring generation quality while significantly improving training efficiency and resource utilization. The final model can autoregressively generate subsequent codes based on the prefix stroke encoding sequence, accurately completing the Chinese character stroke generation process from local to global, providing core technical support for intelligent handwriting generation systems.
[0109] By repeatedly training the stroke prediction model through the above process and combining it with the decoding model to reconstruct the vector strokes, stroke-by-stroke Chinese character generation can be achieved. (e.g.) Figure 6 )
[0110] Image quality assessment
[0111] This method is abbreviated as LVGM, and its generation effect is compared with existing vectorized image methods, for example... Figure 7 The existing methods compared are as follows: DeepSVG directly predicts the content of vector commands, predicting the next vector command itself each time, thereby achieving graphic drawing; DeepVecFont-v2 uses a "raster path map" to define the approximate skeleton and area of the glyph, and another "vector displacement map" to accurately indicate the vector direction of each pixel to the final outline, synthesizing and transforming the vector outline.
[0112] The generation results show that LVGM has a better generation effect in generating complex vector graphics with multiple strokes. DeepSVG and DeepVecFont-v2 both have varying degrees of vector path confusion, resulting in problems such as vector coordinate offset and incorrect vector command type prediction.
[0113] This method is highly innovative in simultaneously generating vectorized glyphs and text content. To comprehensively measure the complex features of the generated characters, an evaluation system was designed from three dimensions: recognizability, aesthetics, and literary quality, with each dimension using a scoring standard from 0 to 5. Fifty domain experts and 150 graduate students in related fields were invited to participate in the evaluation, and all scoring results were summarized and analyzed. These scoring results will serve as the benchmark evaluation basis for the model's quality in vocabulary and poetry generation. The detailed definitions of the specific evaluation dimensions (recognizableness, aesthetics, literary quality, and scoring calculation methods) are as follows:
[0114] Recognizableness: This dimension evaluates each glyph from the perspective of stroke integrity: considering whether there are missing or incorrect strokes, whether the overall character structure is reasonable and has a real meaning, and whether the glyph is easy to be recognized as valid text.
[0115] Aesthetics: Focus on the smoothness of the vector stroke edges, the presence of outliers and spikes, the correctness of the relative positions of each vector stroke, and the overall visual quality of the character.
[0116] Literary Quality: In multi-text generation tasks, contextual coherence is crucial. The presence of meaningless words negatively impacts the overall expressiveness of the text. Therefore, it is essential to assess whether the generated content possesses a certain level of literary quality. This serves as a benchmark for evaluation.
[0117] All generated images were randomized. During the evaluation process, participants observed each image one by one, with each image presented for 3 seconds, and completed their scoring within 5 seconds of the end of the observation period. The scoring results showed that this method has very good performance in vectorized Chinese character generation. (e.g.) Figure 8 )
[0118] This invention, based on an advanced deep learning architecture, proposes a method for generating vector sequences by predicting stroke-by-stroke, which can efficiently and accurately generate high-quality vectorized Chinese characters containing rich semantic information. This technology not only supports single-character generation but can also be extended to the generation of large-scale vector sequences of long sentences, phrases, classical poems, and even paragraphs. While maintaining the rigor of character structure and the standardization of stroke order, it significantly improves the visual aesthetics and cultural coherence of the generated results.
[0119] The generated vectorized Chinese characters adhere to national standard stroke order specifications, with each stroke mathematically represented using parametric curves, ensuring both structural and calligraphic rationality. Visually, the generated characters exhibit smooth strokes, symmetrical structure, and no topological errors or morphological distortions, conforming to general human perceptions of the aesthetic appeal of Chinese handwriting. Furthermore, this method demonstrates excellent generalization ability in cross-font style generation tasks, adapting to various writing styles such as regular script, Song script, and running script, meeting the character shape requirements of different application scenarios.
[0120] This technology further integrates semantic modeling and grammatical constraint mechanisms to ensure that the generated text possesses good readability and logical consistency at the linguistic level. Especially when generating content with high cultural connotations, such as idioms and poems, it maintains high semantic accuracy and literary quality. This invention not only solves the technical bottlenecks in vectorized Chinese character generation, achieving high-precision and high-efficiency serialization output, but also establishes new technical standards in multiple dimensions such as standardization, aesthetics, and semantic integrity. It can be widely applied in fields such as computer-aided design, intelligent calligraphy generation, digital education, and computational cultural heritage.
Claims
1. A method for generating vectorized Chinese character graphics based on a large model, characterized in that, Includes the following steps: Step 1: Data preprocessing; The vectorized Chinese characters used for model training are first decomposed into multiple independent stroke outlines based on their character structure and writing norms, ensuring the writing order between strokes, converting the stroke control points into cubic Bézier curve format, and then normalizing the coordinates. Step 2: Stroke feature extraction; After the initial stroke data is restructured, it is input into a multi-layer convolutional neural network (CNN) for feature extraction. The 8×dim feature map extracted by the multi-layer convolutional neural network is split along the spatial dimension to obtain 8 independent 1×dim feature vectors, where dim represents the preset feature dimension. Step 3 Feature vector discretization encoding; Each 1×dim continuous feature vector is mapped to a discrete code to achieve spatial transformation and reduce modeling complexity; Step 4: Arrange the pens in sequence; The vectorized text content is processed by breaking down each character into independent strokes and arranging them strictly according to their stroke order to form a global stroke sequence. Each stroke is converted into a discrete code through stroke feature extraction and discretization encoding. The discrete codes of all the above strokes are then concatenated in the stroke order of the characters they belong to to construct a complete discrete code sequence. Step 5: Feature encoding prediction; The discrete encoded sequence arranged in stroke order in step four is normalized; the processed sequence is then input into a large language model based on the Transformer architecture for modeling and prediction. Step Six: Encode and Restore Features; The feature encoding prediction generated in step five is restored to a stroke feature representation in continuous space for subsequent vectorized image reconstruction or output. Step 7: Stroke restoration; The 8×dim feature matrix obtained in step six is reversed and restored into individual strokes that can be analyzed by vector graphics software using a deep neural network.
2. The method for generating vectorized Chinese character graphics based on a large model according to claim 1, characterized in that, Step two is as follows: First, the input stroke data with an initial size of 64×6 is restructured, and the 64 dimensions are sequentially decomposed into two dimensions of 8×8, thus transforming it into an 8×8×6 three-dimensional data matrix to meet the input requirements of the subsequent convolutional neural network. Subsequently, the reconstructed data is input into a multi-layer convolutional neural network (CNN) for feature extraction. Finally, the 8×dim feature map extracted by the multi-layer convolutional neural network is split along the spatial dimension to obtain 8 independent 1×dim feature vectors, where dim represents the preset feature dimension. The multi-layer convolutional neural network consists of several convolutional layers, activation function layers, and pooling layers, which can gradually capture multi-level features from local details to global structure in stroke data. The convolution operation uses small-sized convolutional kernels to enhance the ability to perceive subtle changes in strokes, and improves the expressive power of the model through non-linear activation functions. After multiple cascaded convolution operations, the feature map is gradually compressed and abstracted, and finally outputs a feature map of size 8×dim, where dim represents the preset feature dimension; this feature map contains high-level semantic information of the strokes. Each 1×dim feature vector corresponds to a segment or region in the original stroke, representing the depth feature expression of the segment or region respectively; These feature vectors can be used individually for subsequent stroke analysis and recognition tasks, or they can be used as a whole for sequence modeling.
3. The method for generating vectorized Chinese character graphics based on a large model according to claim 1, characterized in that, The specific process of step three is as follows: First, construct a learnable discrete codebook with a size of K×dim, where K represents the total number of preset discrete codes and dim is the dimension of the feature vector; Subsequently, for each continuous feature vector to be encoded, the nearest neighbor search strategy is used to find the cluster center vector with the smallest Euclidean distance in the encoding file; Specifically, the distance between the feature vector and all K vectors in the encoding is calculated, the nearest neighbor index k is selected, and the discrete vector corresponding to the index is used as an approximate representation of the original continuous vector. Finally, the retrieved discrete vector is used as the input to the subsequent sequence prediction model, and the index k can also be directly used as the discretization symbol of the feature to participate in sequence modeling.
4. The method for generating vectorized Chinese character graphics based on a large model according to claim 3, characterized in that, The discrete code is constructed through uniform initialization or clustering based on training data, where each row represents a cluster center vector, i.e. a discrete semantic unit; these units are uniformly distributed in the vector space and collectively cover the continuous feature space.
5. The method for generating vectorized Chinese character graphics based on a large model according to claim 1, characterized in that, Step five is as follows: A large language model based on the Transformer architecture is used to model and predict the discrete encoded sequences generated in the previous steps; First, the discrete coding sequences arranged in stroke order are normalized: a start symbol BOS is added to the beginning of the sequence and an end symbol EOS is added to the end. Padding symbols PAD are used to align sequences of different lengths to meet the requirements of batch training. Subsequently, the processed sequence is input into a large language model based on the Transformer architecture for training; the model predicts the next discrete code in an autoregressive manner, conditioned on the previous code; specifically, at each time step, the model predicts the value of the next code based on all current and previous codes, and this process is iterated until the model outputs the EOS symbol, indicating that the current sequence prediction is complete; During training, the data is divided into several batches for supervised training based on hardware resource configuration, and the model parameters are optimized by gradient descent to minimize the cross-entropy loss between the predicted and the true values.
6. The method for generating vectorized Chinese character graphics based on a large model according to claim 1, characterized in that, Step six specifically involves: First, the predicted encoded sequence is post-processed to remove special control symbols and retain only the effective discrete codes that represent the semantics of strokes. Subsequently, the cleaned discrete coding sequences are grouped sequentially, with 8 codes per group, and each group corresponds to the semantic representation of a complete stroke; Based on the discrete code template constructed in step three, the eight discrete codes in each group are mapped back to their corresponding continuous feature vectors. Finally, the eight retrieved feature vectors are combined in sequence to reconstruct an 8×dim dimensional feature matrix, which represents the high-level semantic features of a stroke.
7. The method for generating vectorized Chinese character graphics based on a large model according to claim 1, characterized in that, Step seven specifically consists of three steps: feature decoding and parameter reconstruction, parameter post-processing and instruction generation, and SVG path construction. The feature decoding and parameter reconstruction methods are as follows: The deep neural network adopts a transposed convolutional neural network with a symmetrical structure to the CNN in step two, which is used to progressively upsample and reconstruct the 8×dim feature matrix into a 64×6 original parameter matrix; the network restores the spatial dimension through multi-layer deconvolution operations, and retains high-frequency details with skip connections, and finally outputs Bézier curve parameters with the same dimension as the input data. The parameter post-processing and instruction generation methods are as follows: The reconstructed 64×6 matrix is processed as follows: rows filled with zeros are filtered out, and valid control point data are retained; each group of 6 parameters is converted into standard SVG cubic Bézier curve instructions; the control point coordinates are inversely normalized according to the scaling factor during coordinate normalization. The SVG path is constructed as follows: The processed Bezier instructions are concatenated according to the following rules: the starting point is located using the M instruction, consecutive Bezier segments are connected using the C instruction, and the closed path is appended with the Z instruction; finally, an SVG path string conforming to the W3C standard is generated, which constitutes a single stroke that can be parsed by any vector graphics software.
Citation Information
Patent Citations
A Chinese vector character generation method based on the Potrace algorithm
CN111666739B
Chinese character style migration method and migration system thereof
CN120220168A
Controllable Chinese character new font generation method and system based on diffusion model
CN120543697A
Chinese character pattern generation method and device, equipment and medium
CN120563664A
Diffusion model character repairing method and device based on dual-condition guidance
CN120298259A