Chinese character skeleton generation method and device, electronic equipment and storage medium
By extracting the handwriting style features and content structure features of the target user, a handwriting trajectory sequence of the target Chinese character is generated, which solves the problem that it is difficult to guarantee the style similarity and structural stability of Chinese character skeleton synthesis in the existing technology, and realizes the generation of Chinese characters with unified style and stable structure.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- IFLYTEK CO LTD
- Filing Date
- 2022-12-28
- Publication Date
- 2026-04-17
AI Technical Summary
In existing technologies, it is difficult to guarantee the style similarity and structural stability of Chinese character skeleton synthesis, and the application scenarios are relatively limited, making it difficult to generate a full set of Chinese characters with a unified style and stable structure.
By identifying handwritten Chinese character images and standard trajectory sequences of the target user, handwriting style features and content structure features are extracted. Image style extraction model and sequence style extraction model are used to generate the handwritten trajectory sequence of the target user, and a skeleton generation model is combined to generate Chinese character skeletons.
It achieves stable handwriting style extraction based on arbitrary and limited handwritten Chinese character images, ensuring style consistency and structural stability between generated Chinese characters and handwritten Chinese characters, and improving the content accuracy and application scope of generated Chinese characters.
Smart Images

Figure CN115937869B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image processing technology, and in particular to a method, apparatus, electronic device, and storage medium for generating Chinese character skeletons. Background Technology
[0002] Reading and writing occupy an extremely important place in people's lives, as they respectively input information from the world and output information to the world. Therefore, how to endow devices with reading (handwritten text recognition) and writing (handwritten text generation) capabilities has become a popular research topic.
[0003] Currently, the technology for handwritten text recognition on devices is relatively mature. However, in terms of handwritten data synthesis, due to the wide variety of Chinese character fonts, there is a lack of research on the skeleton generation of handwritten fonts. In the few existing studies, the variations in the writer's note style, content style, font usage, character spacing, etc., make it difficult for the device to define / predict the appearance of characters, ultimately resulting in a questionable level of naturalness and realism in the synthesized handwritten data. Summary of the Invention
[0004] This invention provides a method, apparatus, electronic device, and storage medium for generating Chinese character skeletons, which addresses the shortcomings of existing technologies in that the style similarity and structural stability of synthesized Chinese character skeletons are difficult to guarantee, and the application scenarios are relatively limited.
[0005] This invention provides a method for generating Chinese character skeletons, comprising:
[0006] Identify the handwritten Chinese character images of the target user, as well as the standard trajectory sequence of the target Chinese characters;
[0007] Style extraction is performed based on the handwritten Chinese character images to obtain the handwriting style features of the target user;
[0008] Content extraction is performed based on the standard trajectory sequence to obtain the content structure features of the target Chinese character;
[0009] Based on the handwriting style features and the content structure features, Chinese character skeletons are generated to obtain the handwriting trajectory sequence of the target Chinese character by the target user.
[0010] According to a method for generating Chinese character skeletons provided by the present invention, the step of extracting style based on the handwritten Chinese character image to obtain the handwriting style features of the target user includes:
[0011] The handwritten Chinese character image is input into the image style extraction model to obtain the handwriting style features of the target user output by the image style extraction model;
[0012] The image style extraction model is obtained by training a sequence style extraction model based on the sample handwritten style features of the sample handwritten Chinese character images and the sample handwritten style features of the sample handwritten Chinese character trajectory sequences corresponding to the sample handwritten Chinese character images.
[0013] The sequence style extraction model is used to extract style based on the sample handwritten Chinese character trajectory sequence to obtain the sample handwritten style features of the sample handwritten Chinese character trajectory sequence.
[0014] According to the Chinese character skeleton generation method provided by the present invention, the image style extraction model is determined based on the following steps:
[0015] Based on the initial image style extraction model and the initial sequence style extraction model, the sample handwriting style features of the sample handwritten Chinese character images and the sample handwriting style features of the sample handwritten Chinese character trajectory sequences are determined respectively.
[0016] Determine the similarity between the handwriting style features of positive samples and the similarity between the handwriting style features of negative samples. The positive samples are handwritten Chinese character images and corresponding handwritten Chinese character trajectory sequences of the same person. The negative samples are handwritten Chinese character images and / or handwritten Chinese character trajectory sequences of different people.
[0017] Based on the similarity between the handwriting style features of the positive samples and the similarity between the handwriting style features of the negative samples, a contrast loss is determined. Based on the contrast loss, the parameters of the initial image style extraction model and the initial sequence style extraction model are adjusted to obtain the image style extraction model and the sequence style extraction model.
[0018] According to a Chinese character skeleton generation method provided by the present invention, the step of adjusting the parameters of the initial image style extraction model and the initial sequence style extraction model based on the contrast loss to obtain the image style extraction model and the sequence style extraction model includes:
[0019] Based on the sample handwritten Chinese character image, the distance between the sample handwritten style features and the initial class center matrix of the initial handwritten style class centers is used to determine the distribution loss; the initial class center matrix is obtained by clustering each handwritten style within the initial handwritten style class centers;
[0020] Based on the distribution loss and the contrast loss, a joint training loss is determined, and based on the joint training loss, the parameters of the initial sequence style extraction model, the initial image style extraction model, and the initial handwriting style class center are adjusted to obtain the sequence style extraction model, the image style extraction model, and the handwriting style class center.
[0021] According to a Chinese character skeleton generation method provided by the present invention, determining the joint training loss based on the distribution loss and the contrast loss includes:
[0022] In the case where any sample handwritten Chinese character image is missing a corresponding sample handwritten Chinese character trajectory sequence, determine the predicted handwritten trajectory sequence corresponding to the sample handwritten Chinese character image;
[0023] Based on the initial sequence style extraction model, the predicted handwriting style features of the predicted handwriting trajectory sequence are determined. The predicted handwriting trajectory sequence is obtained by generating a Chinese character skeleton based on the sample handwriting style features of any sample handwritten Chinese character image and the sample content structure features of the sample standard trajectory sequence of the reference Chinese character.
[0024] Based on the similarity between the sample handwriting style features of any sample handwritten Chinese character image and the predicted handwriting style features of the predicted handwriting trajectory sequence, a consistency loss is determined, and based on the consistency loss, the distribution loss, and the contrast loss, a joint training loss is determined.
[0025] According to a method for generating Chinese character skeletons provided by the present invention, the step of inputting the handwritten Chinese character image into an image style extraction model to obtain the handwriting style features of the target user output by the image style extraction model includes:
[0026] The handwritten Chinese character image is input into the image style extraction model to obtain the initial handwriting style features of the target user output by the image style extraction model;
[0027] A class center matrix is determined to identify the class centers of the handwriting style. Based on the correlation between the initial handwriting style features and the class center matrix, the handwriting style features of the target user are determined.
[0028] According to a method for generating Chinese character skeletons provided by the present invention, the step of generating Chinese character skeletons based on the handwriting style features and the content structure features to obtain the handwriting trajectory sequence of the target user for the target Chinese character includes:
[0029] Based on the handwriting style features and the content structure features, trajectory prediction is performed to obtain the relative positions of each handwriting trajectory point of the target Chinese character;
[0030] Based on the handwriting style features and the content structure features, state prediction is performed to obtain the trajectory state of each handwriting trajectory point of the target Chinese character.
[0031] Based on the relative position and trajectory state of each handwritten trajectory point, a Chinese character skeleton is generated to obtain the handwritten trajectory sequence of the target user for the target Chinese character.
[0032] The present invention also provides a Chinese character skeleton generation device, comprising:
[0033] The data determination unit is used to determine the handwritten Chinese character image of the target user, as well as the standard trajectory sequence of the target Chinese character;
[0034] A style extraction unit is used to extract style based on the handwritten Chinese character image to obtain the handwriting style features of the target user.
[0035] The content extraction unit is used to extract content based on the standard trajectory sequence to obtain the content structure features of the target Chinese character.
[0036] The skeleton generation unit is used to generate Chinese character skeletons based on the handwriting style features and the content structure features, so as to obtain the handwriting trajectory sequence of the target Chinese character by the target user.
[0037] The present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the Chinese character skeleton generation method as described above.
[0038] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the Chinese character skeleton generation method as described above.
[0039] The present invention provides a method, apparatus, electronic device, and storage medium for generating Chinese character skeletons. It extracts style from handwritten Chinese character images and extracts content from standard trajectory sequences, obtaining the handwriting style features of the target user and the content structure features of the target Chinese character. Based on these two features, it generates a Chinese character skeleton, resulting in the handwriting trajectory sequence of the target user for the target Chinese character. This overcomes the shortcomings of traditional methods, such as difficulty in guaranteeing style similarity and structural stability in Chinese character skeleton synthesis, and limited application scenarios. It achieves stable handwriting style extraction based on handwritten Chinese character images containing any and a small number of handwritten Chinese characters. This not only ensures style consistency between the generated Chinese character and the handwritten Chinese character but also improves the content accuracy and structural stability of the generated Chinese character, while ensuring its wide applicability. Attached Figure Description
[0040] To more clearly illustrate the technical solutions in this invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0041] Figure 1This is an example diagram of the handwritten text and stroke sequence provided by the present invention;
[0042] Figure 2 This is a flowchart illustrating the Chinese character skeleton generation method provided by the present invention;
[0043] Figure 3 This is a flowchart illustrating the comparative training process provided by the present invention;
[0044] Figure 4 This is an example image of a binary image of a handwritten Chinese character provided by this invention;
[0045] Figure 5 This is a flowchart illustrating the joint training process provided by the present invention;
[0046] Figure 6 This is a flowchart illustrating the process of determining consistency loss provided by the present invention;
[0047] Figure 7 This is a general framework diagram of the training process of the image style extraction model provided by the present invention;
[0048] Figure 8 This is a flowchart illustrating the process of determining handwriting style features provided by the present invention;
[0049] Figure 9 This is a flowchart illustrating the process of determining the handwritten trajectory sequence provided by the present invention;
[0050] Figure 10 This is a general framework diagram of the Chinese character skeleton generation method provided by the present invention;
[0051] Figure 11 This is a schematic diagram of the structure of the Chinese character skeleton generation device provided by the present invention;
[0052] Figure 12 This is a schematic diagram of the structure of the electronic device provided by the present invention. Detailed Implementation
[0053] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.
[0054] Currently, handwritten text recognition technology in devices is relatively mature, and its recognition accuracy has been greatly improved. However, in the synthesis of handwritten data, variations in the writer's note-taking style, content format, font usage, character spacing, etc., still exist. Figure 1This is an example diagram of handwritten text and stroke sequences provided by the present invention, such as... Figure 1 As shown, the mixed styles of breaks and connections within the writer's writing, variations in glyph usage, and differences in character spacing and slant make it difficult to define / predict the specific appearance of characters, making the synthesis of realistic handwritten data extremely challenging.
[0055] Currently, customizing a personalized font for a user requires a font design team to spend about a year. Font design is time-consuming and labor-intensive, making it difficult for ordinary people to achieve personalized font customization. In this field, for languages such as English and Korean, due to their fewer basic components and simpler structures, there is more research on font synthesis, and the technology is relatively mature. However, for Chinese characters, due to their numerous character categories (over 20,000) and complex structures, there is less research on the skeleton generation of personalized handwritten fonts, and the practical application is poor. Therefore, how to generate a unified style for all Chinese characters has become an urgent technical problem to be solved. At the same time, it can save costs and improve efficiency for ordinary users and professional font production companies.
[0056] Handwritten data is typically represented in two ways: one is as aligned pixels, like a static image written on paper; the other is as... Figure 1 The stroke sequence shown is also the handwritten trajectory sequence. The handwritten Chinese character synthesis aims to imitate handwriting with a specific style, synthesize the corresponding handwritten Chinese character skeleton based on its writing style, and generate the corresponding handwritten stroke sequence.
[0057] Research on handwritten Chinese character synthesis is currently divided into two main categories: one is handwritten Chinese character synthesis based on offline images, and the other is handwritten Chinese character synthesis based on online trajectory points (skeleton sequences). The former is mostly limited to the writing content corresponding to the offline images, and in extracting trajectory sequences based on images, it is often difficult to guarantee the effective extraction of the corresponding trajectory sequences, thus affecting the stylistic similarity of the generated Chinese characters. The latter requires users to input online handwritten skeleton sequences for style extraction, so it is difficult to apply to photography scenarios and has a narrow application scope. That is, it cannot extract the style of user handwritten data in any photography scenario to generate handwritten Chinese characters.
[0058] In short, current handwritten Chinese character synthesis schemes are mostly limited in their application scenarios, namely, they restrict the writing content and writing mode; moreover, the stability and stylistic similarity of the generated handwritten Chinese characters are difficult to guarantee.
[0059] In addition, there are schemes that use generative adversarial networks based on character component information to synthesize handwritten Chinese characters. However, since the generated result is directly in the form of an image and lacks information on the writing stroke order, i.e., the handwriting trajectory sequence, it is difficult to apply to online handwritten data application scenarios, such as smartphones, electronic whiteboards, tablets, and text written in digital ink, and it is also difficult to guarantee the structural stability of the generated Chinese characters.
[0060] In RNN (Recurrent Neural Network)-based solutions, handwritten data can be simulated using RNN-based generator models, but the synthesized results are unstable and cannot synthesize Chinese characters of specific styles. Correspondingly, in FontRNN-based solutions, FontRNN utilizes transfer learning strategies to generate Chinese character skeletons through RNNs; however, this approach focuses on font generation, with each trained model only able to synthesize one font (the same as the training set), and it can only generate fonts from online trajectory sequences, limiting its application scenarios.
[0061] In summary, the current challenge in synthesizing handwritten Chinese characters lies in ensuring consistency in handwriting style between the generated characters and the reference characters, as well as the structural stability of the generated characters. Therefore, how to capture the user's handwriting style from any and a small number of characters written by the user to generate a complete set of Chinese characters with a unified style has become an urgent technical problem to be solved. At the same time, this can save costs and improve efficiency for both ordinary users and professional font production companies.
[0062] In response, this invention provides a method for generating Chinese character skeletons. Based on handwritten Chinese character images containing any small number of handwritten Chinese characters, it extracts handwriting style features and combines them with the content structure features of the target Chinese character. Using the handwriting trajectory sequence of the target Chinese character, it not only ensures the stylistic consistency between the generated Chinese character and the handwritten Chinese character, but also improves the structural stability and content accuracy of the generated Chinese character. Figure 2 This is a flowchart illustrating the Chinese character skeleton generation method provided by the present invention, as shown below. Figure 2 As shown, the method includes:
[0063] Step 210: Determine the handwritten Chinese character image of the target user, and the standard trajectory sequence of the target Chinese character;
[0064] Specifically, before generating the skeleton of Chinese characters, it is necessary to first determine the reference objects. These reference objects correspond to two levels: handwriting style and content structure. The former provides a stylistic reference for the generated Chinese characters, while the latter provides guidance in terms of content and structure. Specifically, the reference objects can be the target user's handwritten Chinese characters presented as images, or the strokes of the target Chinese characters presented as a sequence; these can also be referred to as images of the target user's handwritten Chinese characters, and standard trajectory sequences of the target Chinese characters.
[0065] Here, the target user refers to those who need personalized font customization / handwritten Chinese character skeleton generation; the target Chinese character is the reference character, which can be any Chinese character. It provides guidance in terms of content and structure for the final generated handwritten trajectory sequence. In short, the input of its standard trajectory sequence can ensure the structural stability and content correctness of the generated Chinese character. The standard trajectory sequence (standard stroke sequence) of the target Chinese character can be obtained through online querying / crawling / downloading.
[0066] The handwritten Chinese character image can be obtained by imaging an online skeleton sequence of any Chinese character input by the target user, or by photographing any Chinese character written by the target user on a writing page using an image acquisition device. Here, the image acquisition device can be a camera, webcam, scanner, etc., and the writing page can be a fixed piece of paper, a blackboard / whiteboard, an electronic writing board, etc. It is worth noting that the specific content and number of handwritten Chinese characters in the image are arbitrary and random. In other words, this embodiment of the invention does not limit the specific content or the number of handwritten Chinese characters written by the target user.
[0067] Step 220: Extract style based on handwritten Chinese character images to obtain the handwriting style features of the target user;
[0068] Specifically, after obtaining the handwritten Chinese character image of the target user, style extraction can be performed based on the handwritten Chinese character image to obtain the handwriting style features of the target user. The specific process includes:
[0069] First, style extraction is performed using images of handwritten Chinese characters to extract information about the handwriting style characteristics of the target user. This yields the handwriting style features of the target user. Specifically, handwriting style extraction is performed based on images of handwritten Chinese characters, which extracts information that reflects the internal features and external representation of the target person's handwritten Chinese characters. For example, the writing style, font usage habits, character spacing, character slant, stroke sharpness, and writing trajectory are all extracted from the handwritten Chinese character images to form the handwriting style features of the target person.
[0070] Here, the style extraction process based on handwritten Chinese character images can be achieved through an image style extraction model. That is, the handwritten Chinese character image can be input into the image style extraction model, and then the image style extraction model can perform style extraction based on the input handwritten Chinese character image to extract the handwritten style features of the handwritten Chinese characters contained in the handwritten Chinese character image. Finally, the handwritten style features of the target user output by the image style extraction model can be obtained.
[0071] It is worth noting that before inputting the handwritten Chinese character image into the image style extraction model, the handwritten Chinese character image needs to be segmented. That is, the handwritten Chinese character image can be segmented by a single character detection model to cut it into a series of images containing only a single Chinese character, thereby obtaining multiple independent single Chinese character images. Then, style extraction can be performed based on this series of independent single Chinese character images to obtain the handwriting style features of the target user.
[0072] Step 230: Extract content based on standard trajectory sequences to obtain the content structure features of the target Chinese character;
[0073] Specifically, after obtaining the standard trajectory sequence of the target Chinese character, content extraction can be performed based on the standard trajectory sequence to obtain the content structure features of the target Chinese character. The specific process includes:
[0074] First, content extraction is performed using a standard trajectory sequence to extract information about the glyph content and font structure of the target Chinese character. This yields the content structure features of the target Chinese character. Specifically, content structure extraction is performed based on the standard trajectory sequence of the target Chinese character. This involves extracting information from the standard trajectory sequence that reflects the content representation and structural characteristics of the target Chinese character, such as the content of the written strokes, the order of the written strokes, the stroke tips, the stroke tendencies, the stroke structure of the Chinese character, and the spacing between the written strokes. This yields the content structure features of the target Chinese character, which contain both content and structural information.
[0075] Here, the content extraction process based on the standard trajectory sequence can be achieved through a content structure extraction model. That is, the standard trajectory sequence of the target Chinese character can be input into the content structure extraction model first, and then the content structure extraction model can extract the content structure based on the input standard trajectory sequence to extract the content and structural features of the target Chinese character contained in the standard trajectory sequence. Finally, the content structure features of the target Chinese character output by the content structure extraction model can be obtained.
[0076] Before inputting the standard trajectory sequence into the content structure extraction model, the content structure extraction model can be pre-trained using the standard trajectory sequence of reference Chinese characters and the corresponding sample content structure features. Here, the initial content structure extraction model in the training process can be built on Bi-LSTM (Bi-directional Long Short-Term Memory) network.
[0077] Step 240: Based on handwriting style features and content structure features, generate Chinese character skeletons to obtain the handwriting trajectory sequence of the target user for the target Chinese character.
[0078] Specifically, after obtaining the handwriting style characteristics of the target user and the content structure characteristics of the target Chinese characters through the above process, the skeleton of the Chinese characters can be generated based on these two characteristics to obtain the handwriting trajectory sequence of the target user for the target Chinese characters. The specific process may include:
[0079] By utilizing the handwriting style features of the target user and the content structure features of the target Chinese character, a Chinese character skeleton is generated to obtain the handwriting trajectory sequence of the target user for the target Chinese character. That is, a handwriting trajectory sequence (generated Chinese character) corresponding to the target Chinese character and possessing the handwriting style of the target user can be obtained. Specifically, based on the handwriting style features and content structure features, the handwriting style of the target user is simulated to generate handwritten Chinese characters with the content representation and structural characteristics of the target Chinese character, thereby obtaining the handwriting trajectory sequence. In other words, based on the content structure features of the target Chinese character and referring to the handwriting style features of the target user, a handwriting trajectory sequence that imitates the handwriting style of the target user and corresponds to the content and structural information of the target Chinese character is generated.
[0080] Here, the process of generating Chinese character skeletons based on handwriting style features and content structure features can be implemented based on a skeleton generation model. Specifically, the handwriting style features of the target user and the content structure features of the target Chinese character can be input into the skeleton generation model. Then, the skeleton generation model generates Chinese character skeletons based on the input handwriting style features and content structure features. That is, it generates handwritten Chinese characters that correspond to the handwriting style of the target user and have the content representation and structural characteristics of the target Chinese character, referring to the handwriting style features and content structure features. Finally, the handwriting trajectory sequence corresponding to the target Chinese character can be obtained from the output of the skeleton generation model.
[0081] Before inputting handwriting style features and content structure features into the skeleton generation model, the skeleton generation model can be pre-trained using sample handwriting style features from sample handwritten Chinese character images, sample content structure features from sample standard trajectory sequences of reference Chinese characters, and sample handwritten trajectory sequences. Here, the initial skeleton generation model in the training process can be built on a two-layer bidirectional long short-term memory network.
[0082] It is worth noting that, in order to improve the stylistic similarity of the generated Chinese character skeletons (handwritten trajectory sequences), during the training process of the skeleton generation model, handwritten style consistency constraints based on trajectory sequences can be used to improve the stylistic consistency of the generated Chinese character skeletons. That is, the initial skeleton generation model is trained with the consistency of handwritten style between the predicted handwritten trajectory sequence generated by the model and the sample handwritten trajectory sequence as the constraint condition.
[0083] In this embodiment of the invention, handwriting style features and content structure features are used to imitate the handwritten Chinese character skeleton with the handwriting style of the target user, and generate a handwritten stroke sequence (handwriting trajectory sequence) corresponding to the target Chinese character. This achieves stable handwriting style extraction based on handwritten Chinese character images containing any and a small number of handwritten Chinese characters, ensuring the similarity between the generated Chinese character and the target user's handwriting style, and improving the content correctness and structural stability of the generated Chinese character.
[0084] It should be noted that the handwritten trajectory sequence generated in the embodiments of the present invention can be converted into offline static images through relevant technical means and applied to data enhancement in specific scenarios, which is of great significance for improving the recognition and detection performance of devices in many fields.
[0085] The Chinese character skeleton generation method provided by this invention extracts style from handwritten Chinese character images and extracts content from standard trajectory sequences, respectively obtaining the handwriting style features of the target user and the content structure features of the target Chinese character. Based on these two features, a Chinese character skeleton is generated, resulting in the handwriting trajectory sequence of the target user for the target Chinese character. This method overcomes the shortcomings of traditional schemes, such as difficulty in guaranteeing style similarity and structural stability of Chinese character skeleton synthesis, and limited application scenarios. It achieves stable handwriting style extraction based on handwritten Chinese character images containing any and a small number of handwritten Chinese characters, ensuring not only the style consistency between the generated Chinese character and the handwritten Chinese character, but also improving the content correctness and structural stability of the generated Chinese character, while ensuring the scope of application.
[0086] Based on the above embodiments, in step 220, style extraction is performed based on the handwritten Chinese character image to obtain the handwriting style features of the target user, including:
[0087] The handwritten Chinese character image is input into the image style extraction model to obtain the handwriting style features of the target user output by the image style extraction model.
[0088] The image style extraction model is obtained by training a sequence style extraction model based on the sample handwritten style features of the sample handwritten Chinese character images and the sample handwritten Chinese character trajectory sequences corresponding to the sample handwritten Chinese character images.
[0089] The sequence style extraction model is used to extract style based on the sample handwritten Chinese character trajectory sequence, and obtain the sample handwritten style features of the sample handwritten Chinese character trajectory sequence.
[0090] Specifically, step 220, which involves extracting style from the handwritten Chinese character image to obtain the handwriting style features of the target user, may include the following steps:
[0091] First, the handwritten Chinese character image can be segmented to obtain a series of independent single-character images. Specifically, a single-character detection model can be used to cut the handwritten Chinese character image into a series of images containing only a single Chinese character, thus obtaining multiple independent single-character images. That is, using a single-character detection model, the handwritten Chinese character image is segmented on the basis of each Chinese character contained in the handwritten Chinese character image to obtain a series of independent single-character images.
[0092] Subsequently, style extraction can be performed using this series of independent Chinese character images to obtain the handwriting style features of the target user. Specifically, a preset number of Chinese character images can be randomly selected from multiple independent Chinese character images for style extraction. The selected Chinese character images are input into an image style extraction model, which extracts the information that reflects the internal features and appearance of the target person's handwritten Chinese characters from the handwritten Chinese character images. For example, the writing style, font usage habits, character spacing, character slant, stroke sharpness, and writing trajectory. Finally, the handwriting style features of the target user output by the image style extraction model are obtained.
[0093] Here, the preset number can be set according to the actual situation and actual needs, and can be 5, 10, 15, etc. However, as a preferred embodiment of the present invention, the preset number is set to 10, that is, 10 images are randomly selected from the cut Chinese character images for style extraction.
[0094] Before inputting the handwritten Chinese character image into the image style extraction model, the sample handwritten style features of the sample handwritten Chinese character image and the sample handwritten style features of the corresponding sample handwritten Chinese character trajectory sequence can be applied and combined with the sequence style extraction model to pre-train the image style extraction model. Here, the sequence style extraction model is used to extract style based on the input sample handwritten Chinese character trajectory sequence, and can obtain the sample handwritten style features of the sample handwritten Chinese character trajectory sequence.
[0095] Unlike traditional multi-task training methods, this embodiment of the invention takes into account that the training method of multi-task learning requires complete sharing of abstract representation information between different modalities. If this condition is not met, the model cannot aggregate to obtain matching high-dimensional information representation, which will cause the training of the model to be biased and thus lead to poor model prediction performance. Therefore, this embodiment selects to use the consistency of handwriting style represented by sample handwritten data of image modality and sequence modality for model training to obtain the trained image style extraction model.
[0096] Specifically, during model training, firstly, a large amount of handwritten sample data from both image and sequence modalities needs to be collected, namely, sample handwritten Chinese character images and sample handwritten Chinese character trajectory sequences. Then, the initial style extraction models for the image and sequence modalities can be used to determine the sample handwritten style features of the corresponding modalities. These sample handwritten style features are obtained by style extraction from the sample handwritten data of the corresponding modalities. Subsequently, the similarity between the sample handwritten style features of the image and sequence modalities can be used to iterate the parameters of the initial style extraction models for both the image and sequence modalities, thereby obtaining the trained image and sequence style extraction models, i.e., the image style extraction model and the sequence style extraction model.
[0097] Compared to traditional methods that use the error between predicted and labeled values to drive model parameter updates during training, the training method in this embodiment of the invention, which uses the consistency of handwriting style represented by sample handwritten data from image and sequence modalities, does not require complete sharing of abstract representation information between different modalities. Furthermore, by applying the similarity between the sample handwriting style features of the sample handwritten data from image and sequence modalities to train the initial style extraction model, the initial style extraction model can fully learn the proximity relationship between the sample handwriting style features corresponding to the sample handwritten data from image and sequence modalities. This provides crucial assistance in improving the style similarity between generated Chinese characters and handwritten Chinese characters.
[0098] In this embodiment of the invention, the model training process based on the similarity between handwriting style features of sample handwriting data from different modalities allows the initial style extraction model to determine the similarity between sample handwriting style features based on the similarities and differences between the individuals corresponding to the sample handwriting data. This maximizes the similarity between sample handwriting style features when the sample handwriting data from the image modality and the sequence modality correspond to the same individual, i.e., when the sample handwriting data from the two modalities can constitute positive samples. Conversely, it minimizes the similarity between sample handwriting style features when the sample handwriting data from the image modality and / or the sequence modality correspond to different individuals, i.e., when the sample handwriting data from the same or different modalities can constitute negative samples.
[0099] The method provided in this invention uses the consistency of handwriting styles represented by handwritten data from different modalities as a benchmark for model training. This allows the model to fully learn the proximity relationships between the handwriting style features of handwritten data from different modalities during training, thus providing crucial assistance in improving the style similarity between generated Chinese characters and handwritten Chinese characters. This overcomes the shortcomings of traditional training methods that require complete sharing of abstract representation information between different modalities, resulting in poor model training effects. Furthermore, by utilizing the complementary and corresponding relationships of the same handwriting style between different modalities to train the model, the generalization ability of the model can be improved, thereby enhancing the effectiveness and accuracy of handwriting style feature extraction.
[0100] Based on the above embodiments, Figure 3 This is a flowchart illustrating the comparative training process provided by the present invention, as shown below. Figure 3 As shown, the image style extraction model is determined based on the following steps:
[0101] Step 310: Based on the initial image style extraction model and the initial sequence style extraction model, determine the sample handwriting style features of the sample handwritten Chinese character images and the sample handwriting style features of the sample handwritten Chinese character trajectory sequences, respectively.
[0102] Step 320: Determine the similarity between the handwriting style features of positive samples and the similarity between the handwriting style features of negative samples. Positive samples are handwritten Chinese character images of the same person and the corresponding handwritten Chinese character trajectory sequences. Negative samples are handwritten Chinese character images of different people and / or handwritten Chinese character trajectory sequences.
[0103] Step 330: Based on the similarity between the handwriting style features of positive samples and the similarity between the handwriting style features of negative samples, determine the contrast loss, and based on the contrast loss, adjust the parameters of the initial image style extraction model and the initial sequence style extraction model to obtain the image style extraction model and the sequence style extraction model.
[0104] Specifically, the training process of an image style extraction model may include the following steps:
[0105] Step 310: First, it is necessary to determine the initial style extraction model for the image modality and the initial style extraction model for the sequence modality, namely the initial image style extraction model and the initial sequence style extraction model, respectively. Here, the initial image style extraction model can be built on the basis of a fully convolutional CNN (Convolutional Neural Networks); the initial sequence style extraction model can be built on the basis of Bi-LSTM (Bi-directional Long Short-Term Memory).
[0106] Simultaneously, it is necessary to determine the sample handwritten data for the image modality and the sample handwritten data for the sequence modality, which are respectively sample handwritten Chinese character images and sample handwritten Chinese character trajectory sequences. Here, the sample handwritten dataset consisting of sample handwritten Chinese character images and sample handwritten Chinese character trajectory sequences contains sample handwritten data from multiple individuals in two modalities. In short, the sample handwritten dataset contains sample handwritten data from the same individual in two modalities, as well as sample handwritten data from different individuals in the same or different modalities.
[0107] In practice, it is usually difficult to obtain sample handwritten data of the same person in different modalities, that is, it is impossible to obtain sample handwritten Chinese character images and sample handwritten Chinese character trajectory sequences of the same person at the same time. In this embodiment of the invention, a style transfer method is used to render the sample handwritten Chinese character trajectory sequence into an image and add background information to obtain sample handwritten Chinese character images.
[0108] Specifically, the sample handwritten Chinese character images can be determined through the following process:
[0109] First, it is necessary to obtain the sample handwritten Chinese character trajectory sequence. This sample handwritten Chinese character trajectory sequence can be obtained from trajectory point data on electronic devices. Here, the sample handwritten Chinese character trajectory sequence can be collected through a tablet computer.
[0110] Next, the sample handwritten Chinese character trajectory sequence can be preprocessed to construct a sample handwritten data pair of "trajectory sequence-Chinese character image". Specifically, the sample handwritten Chinese character trajectory sequence can be rendered first to render it into a binary image, thereby obtaining a sample handwritten Chinese character binary image. Figure 4 This is an example image of a binary image of a handwritten Chinese character provided by this invention, such as... Figure 4As shown, after rendering, a binary image without background can be obtained. Then, a background is added to the binary image of the sample handwritten Chinese characters. That is, based on the style transfer method, background information from the real shooting scene is added to the binary image of the sample handwritten Chinese characters to obtain a sample handwritten Chinese character image with background.
[0111] Subsequently, the initial image style extraction model and the initial sequence style extraction model can be used to extract styles from the sample handwritten Chinese character images and the sample handwritten Chinese character trajectory sequences, respectively, to obtain the sample handwritten style features of the sample handwritten Chinese character images and the sample handwritten Chinese character trajectory sequences. Specifically, the sample handwritten Chinese character images and the sample handwritten Chinese character trajectory sequences can be input into the initial image style extraction model and the initial sequence style extraction model, respectively. The initial image style extraction model and the initial sequence style extraction model can then extract styles from the input sample handwritten data of the corresponding modality. Finally, the sample handwritten style features of the sample handwritten Chinese character images and the sample handwritten Chinese character trajectory sequences can be obtained from the output of the initial image style extraction model and the initial sequence style extraction model.
[0112] Step 320: Positive and negative samples need to be determined from the sample handwritten data set. Positive samples can be understood as handwritten data of the same person in different modalities in the sample handwritten data set, while negative samples are handwritten data of different people in the same or different modalities in the sample handwritten data set. Specifically, positive samples can be constructed by selecting handwritten Chinese character images and corresponding handwritten Chinese character trajectory sequences of the same person from the sample handwritten data set. At the same time, negative samples can be constructed by selecting handwritten Chinese character images and / or handwritten Chinese character trajectory sequences of different people from the sample handwritten data set.
[0113] Next, it is necessary to determine the similarity between the sample handwriting style features of the sample handwritten Chinese character images in the positive samples and the sample handwriting style features of the sample handwritten Chinese character trajectory sequences, as well as the similarity between the sample handwriting style features of the sample handwritten Chinese character images in the negative samples and / or the sample handwriting style features of the sample handwritten Chinese character trajectory sequences. That is, to calculate the similarity between the sample handwriting style features of the positive samples and the similarity between the sample handwriting style features of the negative samples. It is worth noting that the similarity between the sample handwriting style features here can be measured by cosine similarity, Euclidean distance, Minkowski distance, etc.
[0114] Step 330: Then, based on the similarity between the sample handwriting style features of positive samples and the similarity between the sample handwriting style features of negative samples, the loss of the model comparison training process, i.e., the comparison loss, can be calculated by using the similarity between the sample handwriting style features of sample handwritten Chinese character images in positive samples and the sample handwriting style features of sample handwritten Chinese character trajectory sequences, and the similarity between the sample handwriting style features of sample handwritten Chinese character images in negative samples and / or the sample handwriting style features of sample handwritten Chinese character trajectory sequences as a benchmark.
[0115] The initial training objective of the image style extraction model is to maximize the similarity between the handwriting style features of handwritten samples from different modalities when the handwritten samples constitute positive samples (i.e., handwritten samples from different modalities correspond to the same person); and conversely, to minimize the similarity between the handwritten style features of handwritten samples from the same or different modalities when the handwritten samples constitute negative samples (i.e., handwritten samples from the same or different modalities correspond to different people).
[0116] Therefore, when the similarity between the handwriting style features of each sample in the positive samples is high and the similarity between the handwriting style features of each sample in the negative samples is low, the contrast loss can be determined to be small; correspondingly, when the similarity between the handwriting style features of each sample in the positive samples is low and / or the similarity between the handwriting style features of each sample in the negative samples is high, the contrast loss can be determined to be large.
[0117] Subsequently, the parameters of the initial style extraction models for the two modalities can be iterated based on the contrastive loss. Specifically, the parameters of the initial image style extraction model and the initial sequence style extraction model can be adjusted using the contrastive loss so that the adjusted initial style extraction models for the two modalities can determine the similarity between the handwritten style features of the samples as high as possible when the handwritten data samples from different modalities belong to positive samples, and correspondingly, determine the similarity between the handwritten style features of the samples as low as possible when the handwritten data samples from the same or different modalities belong to negative samples. Finally, the trained style extraction models for the two modalities, namely the image style extraction model and the sequence style extraction model, are obtained.
[0118] Based on the above embodiments, Figure 5 This is a flowchart illustrating the joint training process provided by the present invention, as shown below. Figure 5 As shown, based on contrastive loss, the parameters of the initial image style extraction model and the initial sequence style extraction model are adjusted to obtain the image style extraction model and the sequence style extraction model, including:
[0119] Step 510: Determine the distribution loss based on the distance between the sample handwritten Chinese character image's sample handwritten style features and the initial class center matrix of the initial handwritten style class centers; the initial class center matrix is obtained by clustering each handwritten style within the initial handwritten style class centers.
[0120] Step 520: Based on the distribution loss and contrast loss, determine the joint training loss, and based on the joint training loss, adjust the parameters of the initial sequence style extraction model, the initial image style extraction model, and the initial handwritten style class center to obtain the sequence style extraction model, the image style extraction model, and the handwritten style class center.
[0121] Specifically, the process of adjusting the parameters of the initial style extraction models for the two modalities based on the contrast loss to obtain the style extraction models for the two modalities may include:
[0122] To ensure the stability of Chinese character skeleton generation for handwritten Chinese characters from outside the domain during the Chinese character skeleton generation process, in this embodiment of the invention, the image style extraction model also needs to be jointly trained with the writing style class center based on attention similarity during the training process.
[0123] Step 510: First, it is necessary to determine the initial class center matrix of the initial handwriting style class centers. This can be obtained by clustering each handwriting style within the initial handwriting style class centers. Specifically, it can be obtained by clustering the handwriting style class centers based on the prototype clustering method, thereby obtaining the initial class center matrix of the initial handwriting style class centers.
[0124] Next, the distance between the sample handwritten style features of the sample handwritten Chinese character image and the initial class center matrix of the initial handwritten style class center can be calculated, and the distribution loss of the joint training process can be determined based on this distance. Specifically, the distance cross-entropy method can be used to measure the distance between the sample handwritten style features of the sample handwritten Chinese character image and the initial class center matrix, and the distribution loss of the joint training process can be determined based on this distance.
[0125] Step 520: Subsequently, the loss of the joint training process can be determined based on the distribution loss and the contrastive loss, i.e., the joint training loss, which is determined by combining the contrastive loss and the distribution loss. Specifically, if both the contrastive loss and the distribution loss are small, the joint training loss can be determined to be small; if both the contrastive loss and the distribution loss are large, the joint training loss can be determined to be large; and if the contrastive loss is large and the distribution loss is small, or vice versa, the weights of the contrastive loss and the distribution loss can be combined to measure the magnitude of the joint training loss.
[0126] Subsequently, the parameters of the initial style extraction models and initial handwriting style class centers of the two modalities can be adjusted based on the joint training loss, thereby obtaining the style extraction models and handwriting style class centers of the two modalities. Specifically, the parameters of the initial sequence style extraction model and the initial image style extraction model can be adjusted using the contrastive loss in the joint training loss, so that the adjusted initial style extraction models of the two modalities can judge the similarity between the handwriting style features of the samples based on the similarities and differences of the corresponding personnel in the sample handwriting data. At the same time, the parameters of the image style extraction model and the initial handwriting style class centers can be adjusted based on the distribution loss, so that the initial class center matrix of the adjusted initial handwriting style class centers is more conducive to the measurement of attention similarity and the stability of Chinese character skeleton generation. Finally, the trained sequence style extraction model, image style extraction model, and handwriting style class centers are obtained.
[0127] Based on the above embodiments, Figure 6 This is a flowchart illustrating the process for determining consistency loss provided by the present invention, as shown below. Figure 6 As shown, based on the distribution loss and contrastive loss, the joint training loss is determined, including:
[0128] Step 610: In the case that any sample handwritten Chinese character image is missing the corresponding sample handwritten Chinese character trajectory sequence, determine the predicted handwritten trajectory sequence corresponding to the sample handwritten Chinese character image.
[0129] Step 620: Based on the initial sequence style extraction model, determine the predicted handwriting style features of the predicted handwriting trajectory sequence. The predicted handwriting trajectory sequence is obtained by generating the Chinese character skeleton based on the sample handwriting style features of the sample handwritten Chinese character image and the sample content structure features of the sample standard trajectory sequence of the reference Chinese character.
[0130] Step 630: Based on the similarity between the sample handwriting style features of the sample handwritten Chinese character image and the predicted handwriting style features of the predicted handwriting trajectory sequence, determine the consistency loss, and based on the consistency loss, distribution loss and contrast loss, determine the joint training loss.
[0131] Specifically, the process of determining the joint training loss based on the distribution loss and contrastive loss described above may include the following steps:
[0132] Considering that during the training process of the image style extraction model, not all sample handwritten Chinese character images are obtained by rendering and adding backgrounds based on the sample handwritten Chinese character trajectory sequence, there are also some sample handwritten Chinese character images that are directly collected, or the sample handwritten Chinese character trajectory sequence is accidentally lost after the sample handwritten data pairs are formed, leaving only the sample handwritten Chinese character images.
[0133] For sample handwritten Chinese character images in such cases, the corresponding sample handwritten Chinese character trajectory sequence is missing. In this case, in order to ensure the consistency of the generated predicted handwritten trajectory sequence with the sample handwritten Chinese character image in terms of handwriting style, that is, to make the generated predicted handwritten trajectory sequence more similar in style, in this embodiment of the invention, consistency loss based on handwriting style features can be used to improve the style consistency of the generated Chinese character skeleton.
[0134] Specifically, if any handwritten Chinese character image in the sample handwritten dataset lacks the corresponding handwritten Chinese character trajectory sequence, that is, if the handwritten Chinese character image was directly acquired rather than rendered from data, or if the corresponding handwritten Chinese character trajectory sequence is missing, then it is necessary to determine the predicted handwritten trajectory sequence corresponding to the handwritten Chinese character image. Here, the predicted handwritten trajectory sequence is obtained by generating the Chinese character skeleton using the handwritten style features of the handwritten Chinese character image and the content structure features of the reference Chinese character. The process of generating the Chinese character skeleton has been explained in detail above and will not be repeated here.
[0135] Then, the generated predicted handwritten trajectory sequence can be style extracted by the initial style extraction model of the sequence modality to obtain the predicted handwritten style features of the predicted handwritten trajectory sequence. Specifically, the generated predicted handwritten trajectory sequence can be input into the initial sequence style extraction model, and the initial sequence style model can perform style extraction. Finally, the sample handwritten style features of the predicted handwritten trajectory sequence output by the initial sequence style model can be obtained.
[0136] Then, the similarity between the sample handwriting style features of the handwritten Chinese character image and the predicted handwriting style features of the predicted handwriting trajectory sequence can be calculated. The similarity between features can be measured by cosine similarity, Euclidean distance, Minkowski distance, etc. Based on this similarity, the loss in handwriting style during model training can be determined, i.e., the consistency loss based on handwriting style. Then, based on the consistency loss, distribution loss, and contrast loss, the joint training loss can be determined. That is, the loss in the joint training process is measured by combining the consistency loss based on handwriting style, the distribution loss, and the contrast loss.
[0137] Specifically, when the consistency loss, contrastive loss, and distribution loss are all small, the joint training loss can be determined to be small; when the consistency loss, contrastive loss, and distribution loss are all large, the joint training loss can be determined to be large; and when the three losses have different trends, the magnitude of the joint training loss can be measured by combining the weights of each loss.
[0138] Based on the above embodiments, Figure 7 This is a general framework diagram of the training process of the image style extraction model provided by the present invention, as shown below. Figure 7 As shown, the training process of the image style extraction model specifically includes:
[0139] To improve the handwriting style extraction capability of image style extraction models, specifically enhancing the effectiveness, stability, and style similarity of extracted handwriting style features, this invention proposes a training scheme for a cross-modal initial style extraction model, as follows:
[0140] Considering that it is usually difficult to obtain sample handwritten Chinese character images and corresponding sample handwritten Chinese character trajectory sequences from the same person in practice, the style transfer method is used in this embodiment of the invention to render the sample handwritten Chinese character trajectory sequence into an image and add background information to obtain sample handwritten Chinese character images.
[0141] Here, the sample handwritten Chinese character trajectory sequence can originate from trajectory point data on an electronic device. That is, the sample handwritten Chinese character trajectory sequence can be collected via a tablet computer and can be considered as a label for the sample handwritten Chinese character image. Furthermore, it can be represented as a series of trajectory points ordered by time. Each trajectory point consists of coordinates (x, y) on the electronic device and a pen lift-off event. The pen coordinates are integer values limited by the screen resolution. When the pen is lifted from the screen, the pen lift-off event is recorded as 1; otherwise, it is 0. Therefore, the sample handwritten Chinese character trajectory sequence can be defined as... Where, x t Let t represent the t-th trajectory point, and T represent the total number of trajectory points.
[0142] During training, the handwritten sample data (trajectory sequence) input at a certain moment can be defined as the relative position of the trajectory point coordinates at the current moment and the trajectory point coordinates at the previous moment, consisting of real-valued pairs x = (x1, x2) and a binary identifier x3, which can be represented as:
[0143]
[0144] In the formula, P represents the relative position of each trajectory point; x3 represents the state of the pen lift-off event, that is, when the stroke of the current trajectory point ends, or when the pen is lifted off the screen, then x3 = 1, otherwise x3 = 0.
[0145] During model training, the characteristic that handwriting samples from the same person across different modalities share a similar handwriting style is utilized to train a cross-modal initial style extraction model. This aims to bring the handwriting styles of the same person across two modalities closer together to the same feature space, thereby improving the model's ability to extract handwriting styles. Here, the cross-modal initial style extraction model includes an initial sequence style extraction model and an initial image style extraction model. A contrastive learning strategy is used to bring the handwriting style features of samples from the same person across different modalities closer together, while simultaneously widening the gaps between the handwriting style features of samples from different people.
[0146] Specifically, the input to the initial sequence style extraction model is the relative position P of each trajectory point, which can extract the sample handwriting style features seq_feat based on the input data; the input to the initial image style extraction model is the sample handwritten Chinese character image, which can extract the sample handwriting style features img_feat based on the input data; during training, based on the contrastive learning strategy, the contrastive loss (triplet_loss) is used to bring the sample handwriting style features of the same person's sample handwriting data in two modalities closer together, and to separate the sample handwriting style features of different people's sample handwriting data in the same or different modalities.
[0147] For the image style extraction model, a distribution loss (dist_loss) is also used to train the initial handwriting style class centers based on prototype clustering. The matrix parameters of the initial class center matrix are used as the class center parameters of the second-stage network for training.
[0148] To ensure the effectiveness of style extraction, the initial style extraction model employs a consistency loss during training for handwritten samples from the same individual. This loss narrows the distance between the handwritten style features seq_feat and img_feat of the same individual. Specifically, for unlabeled handwritten Chinese character images—in short, handwritten Chinese character images lacking corresponding handwritten trajectory sequences—a consistency loss (cycle_loss) based on handwritten style features can be used to improve the style consistency of the generated Chinese character skeleton. This involves inputting the generated predicted handwritten trajectory sequence into the initial sequence style extraction model to extract the predicted handwritten style features and then measuring the distance between these features and the corresponding handwritten style features of the handwritten Chinese character images. This narrows the distance between the two features, thereby achieving consistency constraints based on handwritten style.
[0149] The overall loss during model training can be expressed as:
[0150] loss = L triplet_loss +L dist_loss +L cycle_loss
[0151] In the formula, Loss is the overall loss, i.e., the joint training loss.
[0152] The method provided in this invention, by training an initial image style extraction model, enables the converged image style extraction model to model and reconstruct the handwriting style of the target user from any small number of handwritten Chinese character images containing the target user's handwriting. This ensures the stability of style extraction based on handwritten Chinese character images and the effectiveness of the extracted handwriting style features. At the same time, it improves the style similarity of handwriting style features, providing crucial assistance for the automatic generation of a large-scale handwritten Chinese character skeleton font library for the target user's handwriting style.
[0153] Based on the above embodiments, Figure 8 This is a flowchart illustrating the process of determining handwriting style features provided by the present invention, as shown below. Figure 8 As shown, the handwritten Chinese character image is input into the image style extraction model to obtain the handwriting style features of the target user output by the image style extraction model, including:
[0154] Step 810: Input the handwritten Chinese character image into the image style extraction model to obtain the initial handwriting style features of the target user output by the image style extraction model;
[0155] Step 810: Determine the class center matrix of handwriting style class centers. Based on the correlation between the initial handwriting style features and the class center matrix, determine the handwriting style features of the target user.
[0156] Specifically, the process of inputting a handwritten Chinese character image into an image style extraction model to obtain the handwriting style features of the target user output by the image style extraction model can include:
[0157] Step 810: First, the handwritten Chinese character image can be input into the image style extraction model. Then, the image style extraction model performs style extraction to extract information from the handwritten Chinese character image that can reflect the internal features and appearance of the target person's handwritten Chinese characters. For example, writing style, font usage habits, character spacing, character slant, stroke sharpness, writing trajectory trend, etc. Finally, the initial handwriting style features of the target user output by the image style extraction model can be obtained.
[0158] Step 820: To ensure the stability of the generated skeleton of Chinese characters with handwritten style from outside the domain, in this embodiment of the invention, after obtaining the initial handwritten style features output by the image style extraction model, it is necessary to perform attention similarity calculation between them and the writing style class center to obtain the final handwritten style features. Specifically, the class center matrix of the handwritten style class center can be determined first. Since the matrix parameters of the initial class center matrix are used as the class center parameters of the two-stage network during the training of the initial handwritten style class center, the class center matrix can be obtained after the training is completed. Then, attention similarity calculation can be performed between the initial handwritten style features and the class center matrix to obtain the handwritten style features of the target user.
[0159] Based on the above embodiments, Figure 9 This is a flowchart illustrating the process of determining the handwritten trajectory sequence provided by the present invention, as shown below. Figure 9 As shown, based on handwriting style features and content structure features, Chinese character skeletons are generated to obtain the handwriting trajectory sequence of the target user for the target Chinese character, including:
[0160] Step 910: Based on handwriting style features and content structure features, perform trajectory prediction to obtain the relative positions of each handwritten trajectory point of the target Chinese character;
[0161] Step 920: Based on handwriting style features and content structure features, perform state prediction to obtain the trajectory state of each handwritten trajectory point of the target Chinese character.
[0162] Step 930: Based on the relative position and trajectory state of each handwritten trajectory point, generate the Chinese character skeleton to obtain the handwritten trajectory sequence of the target Chinese character by the target user.
[0163] Specifically, step 140, which involves generating a Chinese character skeleton based on handwriting style features and content structure features to obtain the handwriting trajectory sequence of the target Chinese character by the target user, may include the following steps:
[0164] Step 910: First, the handwriting style features and content structure features can be used to predict the trajectory in order to obtain the relative position of each handwritten trajectory point of the target Chinese character. Specifically, the handwriting style features of the target user and the content structure features of the target Chinese character can be used as a basis to predict the trajectory and obtain the relative position of each handwritten trajectory point of the target Chinese character.
[0165] Specifically, the skeleton generation network used for Chinese character skeleton generation can be viewed as a decoder built upon a two-layer bidirectional LSTM network. Therefore, when applying the skeleton generation network to generate Chinese character skeletons, the decoder can predict each handwritten trajectory point in the handwritten trajectory sequence based on handwriting style features and content structure features. Specifically, this can be achieved by using a Gaussian Mixed Model (GMM) with an R-bivariate normal distribution to calculate the positional offset (d) of each handwritten trajectory point. x ,d y Modeling is performed by sampling the Gaussian mixture distribution of the relative positions of the handwritten trajectory points predicted by the decoder to obtain the relative positions of each handwritten trajectory point generated by the model decoder.
[0166] Corresponding to the training phase, at the current decoding time t, the predicted handwritten trajectory point p generated at the previous decoding time can be... t-1 The content output c of the content structure extraction model t and sample handwriting style features context By splicing them together, we can get a. t =[p t-1 ,c t ,s context ], a t It can be used to determine the hidden state h of the decoder at the current decoding moment. t =DEC(h t-1 ,a t Finally, h t By performing linear layer mapping, the predicted handwritten trajectory point p output at the current decoding time is predicted. t .
[0167] Step 920: At the same time, state prediction can be performed based on handwriting style features and content structure features to obtain the trajectory state of each handwriting trajectory point of the target Chinese character. Specifically, state prediction can be performed based on the handwriting style features of the target user and the content structure features of the target Chinese character to obtain the trajectory state of each handwriting trajectory point of the target Chinese character.
[0168] Specifically, based on the handwriting style features and content structure features, when performing state prediction through the skeleton generation model regarded as the decoder, a three-class classifier (Softmax layer) can be used to model the state categories (p1, p2, p3) of each handwritten trajectory point. That is, the handwriting state of each handwritten trajectory point of the target Chinese character is obtained by predicting the state class of the decoder.
[0169] Step 930: Subsequently, based on the relative positions of each handwritten trajectory point obtained from trajectory prediction and the trajectory states of each handwritten trajectory point obtained from state prediction, Chinese character skeletons can be generated to obtain the handwritten trajectory sequence of the target user for the target Chinese character. Specifically, based on the relative positions of each handwritten trajectory point and combined with the trajectory states of each handwritten trajectory point, Chinese character skeletons can be generated to generate a handwritten trajectory sequence that has its handwriting style and corresponds to the content and structural information of the target Chinese character.
[0170] Figure 10 This is a general framework diagram of the Chinese character skeleton generation method provided by the present invention, as shown below. Figure 10 As shown, the overall framework of the Chinese character skeleton generation method provided by this invention consists of three parts: an image style extraction model, a content structure extraction model, and a skeleton generation model. The image style extraction model is composed of a fully convolutional CNN, which can process the input handwritten Chinese character image X. s Encoding the initial handwriting style feature S feat =ENC style (X s Furthermore, an attention mechanism is introduced between the image style extraction model and the skeleton generation model to integrate the initial handwritten style features S. feat Attention is calculated between the class center matrix meta_style and the handwriting style class centers to obtain the handwriting style features S. context =attention(S) feat The content structure extraction model consists of a single LSTM network, which can extract the standard trajectory sequence X of the input target Chinese character. c Encoding as content structure feature H context =ENC context (X c The skeleton generation model consists of a two-layer bidirectional LSTM network, which can generate skeletons based on the input handwriting style features S. context and content structure features H contrxt The method involves generating Chinese character skeletons to obtain a sequence of handwritten trajectories. Specifically, the method may include:
[0171] First, identify the handwritten Chinese character images of the target user, as well as the standard trajectory sequence of the target Chinese characters;
[0172] Subsequently, style extraction is performed based on the handwritten Chinese character images to obtain the handwriting style features of the target user. Specifically, the handwritten Chinese character images are input into an image style extraction model to obtain the handwriting style features of the target user output by the image style extraction model. The image style extraction model is trained by combining the sample handwriting style features of the sample handwritten Chinese character images and the sample handwriting style features of the corresponding sample handwritten Chinese character trajectory sequences. The sequence style extraction model is used to extract style based on the sample handwritten Chinese character trajectory sequences to obtain the sample handwriting style features of the sample handwritten Chinese character trajectory sequences.
[0173] The process of inputting handwritten Chinese character images into an image style extraction model to obtain the handwriting style features of the target user output by the image style extraction model includes: inputting handwritten Chinese character images into an image style extraction model to obtain the initial handwriting style features of the target user output by the image style extraction model; determining the class center matrix of handwriting style class centers; and determining the handwriting style features of the target user based on the correlation between the initial handwriting style features and the class center matrix.
[0174] Here, the image style extraction model is determined based on the following steps: Based on the initial image style extraction model and the initial sequence style extraction model, the sample handwritten style features of the sample handwritten Chinese character images and the sample handwritten Chinese character trajectory sequences are determined respectively; the similarity between the sample handwritten style features of positive samples and the similarity between the sample handwritten style features of negative samples are determined, where positive samples are sample handwritten Chinese character images and corresponding sample handwritten Chinese character trajectory sequences of the same person, and negative samples are sample handwritten Chinese character images and / or sample handwritten Chinese character trajectory sequences of different people; based on the similarity between the sample handwritten style features of positive samples and the similarity between the sample handwritten style features of negative samples, the contrast loss is determined, and based on the contrast loss, the parameters of the initial image style extraction model and the initial sequence style extraction model are adjusted to obtain the image style extraction model and the sequence style extraction model.
[0175] Specifically, based on contrastive loss, the parameters of the initial image style extraction model and the initial sequence style extraction model are adjusted to obtain the image style extraction model and the sequence style extraction model. This includes: determining the distribution loss based on the distance between the sample handwritten style features of the sample handwritten Chinese character images and the initial class center matrix of the initial handwritten style class centers; obtaining the initial class center matrix based on the clustering of each handwritten style within the initial handwritten style class centers; determining the joint training loss based on the distribution loss and contrastive loss, and adjusting the parameters of the initial sequence style extraction model, the initial image style extraction model, and the initial handwritten style class centers based on the joint training loss to obtain the sequence style extraction model, the image style extraction model, and the handwritten style class centers.
[0176] Specifically, the joint training loss is determined based on distribution loss and contrast loss, including: determining the predicted handwritten trajectory sequence corresponding to the sample handwritten Chinese character image when the corresponding sample handwritten Chinese character trajectory sequence is missing for any sample handwritten Chinese character image; determining the predicted handwritten style features of the predicted handwritten trajectory sequence based on the initial sequence style extraction model; generating Chinese character skeletons based on the sample handwritten style features of the sample handwritten Chinese character image and the sample content structure features of the reference Chinese character sample standard trajectory sequence; determining the consistency loss based on the similarity between the sample handwritten style features of the sample handwritten Chinese character image and the predicted handwritten style features of the predicted handwritten trajectory sequence; and determining the joint training loss based on the consistency loss, distribution loss, and contrast loss.
[0177] Subsequently, content extraction was performed based on the standard trajectory sequence to obtain the content structure features of the target Chinese character;
[0178] Subsequently, based on handwriting style features and content structure features, Chinese character skeletons are generated to obtain the handwriting trajectory sequence of the target Chinese character by the target user. Specifically, this can be achieved by: predicting the trajectory based on handwriting style features and content structure features to obtain the relative position of each handwriting trajectory point of the target Chinese character; predicting the state based on handwriting style features and content structure features to obtain the trajectory state of each handwriting trajectory point of the target Chinese character; and generating Chinese character skeletons based on the relative position and trajectory state of each handwriting trajectory point to obtain the handwriting trajectory sequence of the target Chinese character by the target user.
[0179] The present invention provides a method that extracts style from handwritten Chinese character images and extracts content from standard trajectory sequences, thereby obtaining the handwriting style features of the target user and the content structure features of the target Chinese character. Based on these two features, a Chinese character skeleton is generated to obtain the handwriting trajectory sequence of the target user for the target Chinese character. This method overcomes the shortcomings of traditional schemes, such as the difficulty in guaranteeing the style similarity and structural stability of the synthesized Chinese character skeleton and the limited application scenarios. It achieves stable handwriting style extraction based on handwritten Chinese character images containing any and a small number of handwritten Chinese characters, which not only ensures the style consistency between the generated Chinese character and the handwritten Chinese character, but also improves the content correctness and structural stability of the generated Chinese character, while ensuring the scope of application.
[0180] The Chinese character skeleton generation device provided by the present invention is described below. The Chinese character skeleton generation device described below can be referred to in correspondence with the Chinese character skeleton generation method described above.
[0181] Figure 11 This is a schematic diagram of the Chinese character skeleton generation device provided by the present invention, as shown below. Figure 11 As shown, the device includes:
[0182] The data determination unit 1110 is used to determine the handwritten Chinese character image of the target user and the standard trajectory sequence of the target Chinese character;
[0183] The style extraction unit 1120 is used to perform style extraction based on the handwritten Chinese character image to obtain the handwriting style features of the target user.
[0184] Content extraction unit 1130 is used to extract content based on the standard trajectory sequence to obtain the content structure features of the target Chinese character;
[0185] The skeleton generation unit 1140 is used to generate Chinese character skeletons based on the handwriting style features and the content structure features, so as to obtain the handwriting trajectory sequence of the target Chinese character by the target user.
[0186] The Chinese character skeleton generation device provided by this invention extracts style from handwritten Chinese character images and extracts content from standard trajectory sequences to obtain the handwriting style features of the target user and the content structure features of the target Chinese character. Based on these two features, a Chinese character skeleton is generated to obtain the handwriting trajectory sequence of the target user for the target Chinese character. This overcomes the shortcomings of traditional methods, such as difficulty in ensuring style similarity and structural stability of Chinese character skeleton synthesis and limited application scenarios. It achieves stable handwriting style extraction based on handwritten Chinese character images containing arbitrary and a small number of handwritten Chinese characters. This not only ensures the style consistency between the generated Chinese character and the handwritten Chinese character, but also improves the content accuracy and structural stability of the generated Chinese character, while ensuring the scope of application.
[0187] Based on the above embodiments, the style extraction unit 1120 is used for:
[0188] The handwritten Chinese character image is input into the image style extraction model to obtain the handwriting style features of the target user output by the image style extraction model;
[0189] The image style extraction model is obtained by training a sequence style extraction model based on the sample handwritten style features of the sample handwritten Chinese character images and the sample handwritten style features of the sample handwritten Chinese character trajectory sequences corresponding to the sample handwritten Chinese character images.
[0190] The sequence style extraction model is used to extract style based on the sample handwritten Chinese character trajectory sequence to obtain the sample handwritten style features of the sample handwritten Chinese character trajectory sequence.
[0191] Based on the above embodiments, the device further includes a model training unit, used for:
[0192] Based on the initial image style extraction model and the initial sequence style extraction model, the sample handwriting style features of the sample handwritten Chinese character images and the sample handwriting style features of the sample handwritten Chinese character trajectory sequences are determined respectively.
[0193] Determine the similarity between the handwriting style features of positive samples and the similarity between the handwriting style features of negative samples. The positive samples are handwritten Chinese character images and corresponding handwritten Chinese character trajectory sequences of the same person. The negative samples are handwritten Chinese character images and / or handwritten Chinese character trajectory sequences of different people.
[0194] Based on the similarity between the handwriting style features of the positive samples and the similarity between the handwriting style features of the negative samples, a contrast loss is determined. Based on the contrast loss, the parameters of the initial image style extraction model and the initial sequence style extraction model are adjusted to obtain the image style extraction model and the sequence style extraction model.
[0195] Based on the above embodiments, the model training unit is used for:
[0196] Based on the sample handwritten Chinese character image, the distance between the sample handwritten style features and the initial class center matrix of the initial handwritten style class centers is used to determine the distribution loss; the initial class center matrix is obtained by clustering each handwritten style within the initial handwritten style class centers;
[0197] Based on the distribution loss and the contrast loss, a joint training loss is determined, and based on the joint training loss, the parameters of the initial sequence style extraction model, the initial image style extraction model, and the initial handwriting style class center are adjusted to obtain the sequence style extraction model, the image style extraction model, and the handwriting style class center.
[0198] Based on the above embodiments, the model training unit is used for:
[0199] In the case where any sample handwritten Chinese character image is missing the corresponding sample handwritten Chinese character trajectory sequence, determine the predicted handwritten trajectory sequence corresponding to the sample handwritten Chinese character image;
[0200] Based on the initial sequence style extraction model, the predicted handwriting style features of the predicted handwriting trajectory sequence are determined. The predicted handwriting trajectory sequence is obtained by generating a Chinese character skeleton based on the sample handwriting style features of the sample handwritten Chinese character image and the sample content structure features of the sample standard trajectory sequence of the reference Chinese character.
[0201] Based on the similarity between the sample handwriting style features of the sample handwritten Chinese character image and the predicted handwriting style features of the predicted handwriting trajectory sequence, a consistency loss is determined, and based on the consistency loss, the distribution loss, and the contrast loss, a joint training loss is determined.
[0202] Based on the above embodiments, the style extraction unit 1120 is used for:
[0203] The handwritten Chinese character image is input into the image style extraction model to obtain the initial handwriting style features of the target user output by the image style extraction model;
[0204] A class center matrix is determined to identify the class centers of the handwriting style. Based on the correlation between the initial handwriting style features and the class center matrix, the handwriting style features of the target user are determined.
[0205] Based on the above embodiments, the skeleton generation unit 1140 is used for:
[0206] Based on the handwriting style features and the content structure features, trajectory prediction is performed to obtain the relative positions of each handwriting trajectory point of the target Chinese character;
[0207] Based on the handwriting style features and the content structure features, state prediction is performed to obtain the trajectory state of each handwriting trajectory point of the target Chinese character.
[0208] Based on the relative position and trajectory state of each handwritten trajectory point, a Chinese character skeleton is generated to obtain the handwritten trajectory sequence of the target user for the target Chinese character.
[0209] Figure 12 An example is a schematic diagram of the physical structure of an electronic device, such as... Figure 12 As shown, the electronic device may include a processor 1210, a communications interface 1220, a memory 1230, and a communication bus 1240. The processor 1210, communications interface 1220, and memory 1230 communicate with each other via the communication bus 1240. The processor 1210 can call logical instructions in the memory 1230 to execute a Chinese character skeleton generation method. This method includes: determining a handwritten Chinese character image of a target user and a standard trajectory sequence of the target Chinese character; performing style extraction based on the handwritten Chinese character image to obtain the handwriting style features of the target user; performing content extraction based on the standard trajectory sequence to obtain the content structure features of the target Chinese character; and generating a Chinese character skeleton based on the handwriting style features and the content structure features to obtain the handwriting trajectory sequence of the target user for the target Chinese character.
[0210] Furthermore, the logical instructions in the aforementioned memory 1230 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, essentially, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0211] On the other hand, the present invention also provides a computer program product, the computer program product comprising a computer program stored on a non-transitory computer-readable storage medium, the computer program comprising program instructions, wherein when the program instructions are executed by a computer, the computer is able to execute the Chinese character skeleton generation method provided by the above methods, the method comprising: determining a handwritten Chinese character image of a target user and a standard trajectory sequence of the target Chinese character; performing style extraction based on the handwritten Chinese character image to obtain the handwriting style features of the target user; performing content extraction based on the standard trajectory sequence to obtain the content structure features of the target Chinese character; and performing Chinese character skeleton generation based on the handwriting style features and the content structure features to obtain the handwriting trajectory sequence of the target user for the target Chinese character.
[0212] In another aspect, the present invention also provides a non-transitory computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the Chinese character skeleton generation method provided by the above methods. The method includes: determining a handwritten Chinese character image of a target user and a standard trajectory sequence of the target Chinese character; performing style extraction based on the handwritten Chinese character image to obtain the handwriting style features of the target user; performing content extraction based on the standard trajectory sequence to obtain the content structure features of the target Chinese character; and generating a Chinese character skeleton based on the handwriting style features and the content structure features to obtain the handwriting trajectory sequence of the target user for the target Chinese character.
[0213] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.
[0214] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.
[0215] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for generating the skeleton of a Chinese character, characterized in that, include: Identify the handwritten Chinese character images of the target user, as well as the standard trajectory sequence of the target Chinese characters; Style extraction is performed based on the handwritten Chinese character images to obtain the handwriting style features of the target user; Content extraction is performed based on the standard trajectory sequence to obtain the content structure features of the target Chinese character; Based on the handwriting style features and the content structure features, Chinese character skeletons are generated to obtain the handwriting trajectory sequence of the target user for the target Chinese character; The step of extracting style features from the handwritten Chinese character image to obtain the handwriting style features of the target user includes: The handwritten Chinese character image is input into the image style extraction model to obtain the handwriting style features of the target user output by the image style extraction model; The image style extraction model is obtained by training a sequence style extraction model based on the sample handwritten style features of the sample handwritten Chinese character image and the sample handwritten style features of the sample handwritten Chinese character trajectory sequence corresponding to the sample handwritten Chinese character image. The sequence style extraction model is used to extract style based on the sample handwritten Chinese character trajectory sequence to obtain the sample handwritten style features of the sample handwritten Chinese character trajectory sequence.
2. The method for generating Chinese character skeletons according to claim 1, characterized in that, The image style extraction model is determined based on the following steps: Based on the initial image style extraction model and the initial sequence style extraction model, the sample handwriting style features of the sample handwritten Chinese character images and the sample handwriting style features of the sample handwritten Chinese character trajectory sequences are determined respectively. Determine the similarity between the handwriting style features of positive samples and the similarity between the handwriting style features of negative samples. The positive samples are handwritten Chinese character images and corresponding handwritten Chinese character trajectory sequences of the same person. The negative samples are handwritten Chinese character images and / or handwritten Chinese character trajectory sequences of different people. Based on the similarity between the handwriting style features of the positive samples and the similarity between the handwriting style features of the negative samples, a contrast loss is determined. Based on the contrast loss, the parameters of the initial image style extraction model and the initial sequence style extraction model are adjusted to obtain the image style extraction model and the sequence style extraction model.
3. The method for generating Chinese character skeletons according to claim 2, characterized in that, The step of adjusting the parameters of the initial image style extraction model and the initial sequence style extraction model based on the contrast loss to obtain the image style extraction model and the sequence style extraction model includes: The distribution loss is determined based on the distance between the sample handwritten Chinese character images and the initial class center matrix of the initial handwritten style class centers; the initial class center matrix is obtained by clustering each handwritten style within the initial handwritten style class centers. Based on the distribution loss and the contrast loss, a joint training loss is determined, and based on the joint training loss, the parameters of the initial sequence style extraction model, the initial image style extraction model, and the initial handwriting style class center are adjusted to obtain the sequence style extraction model, the image style extraction model, and the handwriting style class center.
4. The method for generating Chinese character skeletons according to claim 3, characterized in that, The determination of the joint training loss based on the distribution loss and the contrastive loss includes: In the case where any sample handwritten Chinese character image is missing a corresponding sample handwritten Chinese character trajectory sequence, determine the predicted handwritten trajectory sequence corresponding to the sample handwritten Chinese character image; Based on the initial sequence style extraction model, the predicted handwriting style features of the predicted handwriting trajectory sequence are determined. The predicted handwriting trajectory sequence is obtained by generating a Chinese character skeleton based on the sample handwriting style features of any sample handwritten Chinese character image and the sample content structure features of the sample standard trajectory sequence of the reference Chinese character. Based on the similarity between the sample handwriting style features of any sample handwritten Chinese character image and the predicted handwriting style features of the predicted handwriting trajectory sequence, a consistency loss is determined, and based on the consistency loss, the distribution loss, and the contrast loss, a joint training loss is determined.
5. The method for generating Chinese character skeletons according to any one of claims 1 to 4, characterized in that, The step of inputting the handwritten Chinese character image into an image style extraction model to obtain the handwriting style features of the target user output by the image style extraction model includes: The handwritten Chinese character image is input into the image style extraction model to obtain the initial handwriting style features of the target user output by the image style extraction model; A class center matrix is determined to identify the class centers of the handwriting style. Based on the correlation between the initial handwriting style features and the class center matrix, the handwriting style features of the target user are determined.
6. The method for generating Chinese character skeletons according to any one of claims 1 to 4, characterized in that, The step of generating a Chinese character skeleton based on the handwriting style features and the content structure features to obtain the handwriting trajectory sequence of the target user for the target Chinese character includes: Based on the handwriting style features and the content structure features, trajectory prediction is performed to obtain the relative positions of each handwriting trajectory point of the target Chinese character; Based on the handwriting style features and the content structure features, state prediction is performed to obtain the trajectory state of each handwriting trajectory point of the target Chinese character. Based on the relative position and trajectory state of each handwritten trajectory point, a Chinese character skeleton is generated to obtain the handwritten trajectory sequence of the target user for the target Chinese character.
7. A Chinese character skeleton generation device, characterized in that, include: The data determination unit is used to determine the handwritten Chinese character image of the target user, as well as the standard trajectory sequence of the target Chinese character; A style extraction unit is used to extract style based on the handwritten Chinese character image to obtain the handwriting style features of the target user. The content extraction unit is used to extract content based on the standard trajectory sequence to obtain the content structure features of the target Chinese character. The skeleton generation unit is used to generate Chinese character skeletons based on the handwriting style features and the content structure features, so as to obtain the handwriting trajectory sequence of the target Chinese character by the target user; The step of extracting style features from the handwritten Chinese character image to obtain the handwriting style features of the target user includes: The handwritten Chinese character image is input into the image style extraction model to obtain the handwriting style features of the target user output by the image style extraction model; The image style extraction model is obtained by training a sequence style extraction model based on the sample handwritten style features of the sample handwritten Chinese character image and the sample handwritten style features of the sample handwritten Chinese character trajectory sequence corresponding to the sample handwritten Chinese character image. The sequence style extraction model is used to extract style based on the sample handwritten Chinese character trajectory sequence to obtain the sample handwritten style features of the sample handwritten Chinese character trajectory sequence.
8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the Chinese character skeleton generation method as described in any one of claims 1 to 6.
9. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the Chinese character skeleton generation method as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Chinese word stock automatic generation method based on writing style modeling
CN106384094A
Handwritten image generation method, model training method, device and equipment
CN113516136A