A Chinese font generation method and system based on nested encoding-decoding network
Directly processing Chinese characters through the nested encoding-decoding network solves the defect of relying on decomposition for Chinese character font migration in the existing technology, and achieves efficient Chinese character font generation and conversion, especially in the processing of stroke details and clarity, and achieves remarkable results.
Patent Information
- Application Number
- CN202111664197.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-31
- Publication Date
- 2024-10-25
- Estimated Expiration
- 2041-12-31
AI Technical Summary
Existing Chinese character font migration methods rely on Chinese character stroke decomposition, which makes it difficult to handle Chinese characters with a large number of strokes. In addition, early preprocessing is time-consuming and relies on prior knowledge, resulting in poor generation results.
Using a method based on nested encoding-decoding networks, the Chinese character migration module and discriminator module are constructed through the training sample set, and Chinese characters are directly processed as images to achieve end-to-end font migration, simplifying the generation process and improving the generation effect.
It realizes automatic conversion between printed fonts and between printed fonts and handwritten fonts, simplifies the font generation process, and enhances the generation effect, especially in handling the details and clarity of strokes.
Smart Images

Figure CN114330237B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of deep learning technology, and in particular to a Chinese font generation method and system based on a nested encoding-decoding network. Background Art
[0002] As we all know, there are more than 70,000 Chinese characters, and more than 3,000 commonly used Chinese characters. When a designer designs a font, he needs to design every Chinese character under the font. When designing a calligrapher's font, the calligrapher also needs to write almost all the commonly used Chinese characters. Therefore, Chinese character font design is a very time-consuming and arduous task. It is of great practical significance to explore a more efficient design method: that is, how to manually design only some of the Chinese characters under a font and automatically generate the remaining Chinese characters under the font.
[0003] In recent years, deep learning, with deep neural networks as its main feature, has been widely used in many fields, greatly promoting the development of fields such as image recognition, object detection, video prediction, and natural language processing. Unlike English, which has only 26 letters, there are more than 3,000 commonly used Chinese characters, and some Chinese characters have many strokes and complex structures; Chinese fonts are also diverse, such as Songti, Kaiti, Fangsong, Heiti... including various handwritten fonts of famous calligraphers or ordinary people. Therefore, in the field of Chinese font migration, there are relatively few studies on Chinese font migration using deep learning.
[0004] Existing related research often adopts methods based on the decomposition and reorganization of Chinese character strokes. One method is: Chinese characters in the source font and the real target font are hierarchically decomposed into radicals, strokes and other components. The model is trained to "remember" the shape of each radical and stroke in the target font. In the test phase of the model, the source font is also decomposed into components, and then each component is matched with the best component in the target font, and finally combined to generate the target font. Another method uses a deep neural network to generate radicals or strokes similar to the target font.
[0005] The disadvantage of the above two font migration methods based on Chinese character decomposition is that the method is highly dependent on the quality of the decomposition results. It is difficult to properly decompose Chinese characters with many strokes and complex structures, and such decomposition is unnecessary for Chinese characters with few strokes. Therefore, these directly affect the subsequent generation of the target font. Secondly, the preprocessing of the method based on Chinese character decomposition is very time-consuming, and the decomposition process requires a lot of prior knowledge. Summary of the invention
[0006] The purpose of the present invention is to provide a Chinese font generation method and system based on a nested encoding-decoding network, which can simplify the font generation process, realize automatic conversion between printed fonts and between printed fonts and handwritten fonts, and solve the problem of generating Chinese character stroke details.
[0007] To achieve the above object, the present invention provides the following solutions:
[0008] A Chinese font generation method based on a nested encoder-decoder network, the Chinese font generation method based on a nested encoder-decoder network comprising:
[0009] Acquire a training sample set; the training sample set includes a source font sample file, a target font sample file and a target font number; the target font sample file includes some target characters; the source font sample file includes source characters corresponding to the target characters in the target font sample file;
[0010] According to the training sample set, a nested encoder-decoder network is trained to obtain a font generation model;
[0011] Based on the font generation model, a complete target font file is generated according to the complete source font file and the target font number.
[0012] Optionally, the nested encoding-decoding network includes a Chinese character migration module and a discriminator module;
[0013] The step of training the nested encoder-decoder network according to the training sample set to obtain a font generation model specifically includes:
[0014] Generate a source font image domain according to the source font sample file; generate a target font image domain according to the target font sample file;
[0015] Converting the source font image domain into a source binary text image; Converting the target font image domain into a target binary text image;
[0016] Determine the target font category data according to the target font number and a pre-set lookup table; the lookup table is a two-dimensional table, the first dimension is the font number, and the second dimension is the font category data; the font category data is a pre-designed font feature;
[0017] Using the Chinese character migration module to perform feature fusion on the source binary text image and the target font category data to obtain a feature fusion image;
[0018] Using the discriminator module to discriminate the authenticity of the feature fusion image and the accuracy of the font category;
[0019] Determine the loss function of the Chinese character migration module according to the target binary text image, the source binary text image, the feature fusion image and the authenticity and accuracy of the feature fusion image;
[0020] Determining a loss function of the discriminator module according to the authenticity of the feature fusion image and the accuracy of the font category;
[0021] The Chinese character migration module is iteratively trained according to the loss function of the Chinese character migration module, and the discriminator module is iteratively trained according to the loss function of the discriminator module, until the loss functions of the Chinese character migration module and the discriminator module converge, so as to obtain an optimal nested encoder-decoder network, and the optimal nested encoder-decoder network is a font generation model.
[0022] To achieve the above object, the present invention also provides the following solution:
[0023] A Chinese font generation system based on a nested encoder-decoder network, the Chinese font generation system based on a nested encoder-decoder network comprising:
[0024] A sample acquisition unit is used to acquire a training sample set; the training sample set includes a source font sample file, a target font sample file and a target font number; the target font sample file includes some target characters; the source font sample file includes source characters corresponding to the target characters in the target font sample file;
[0025] A training unit, connected to the sample acquisition unit, for training the nested encoder-decoder network according to the training sample set to obtain a font generation model;
[0026] The font generation unit is connected to the training unit and is used to generate a complete target font file based on the font generation model and according to the complete source font file and the target font number.
[0027] According to the specific embodiments provided by the present invention, the present invention discloses the following technical effects: by constructing a nested encoding-decoding network, the nested encoding-decoding network is trained using some target characters and corresponding source characters to obtain a font generation model, and then based on the font generation model, a complete target font file is generated according to the complete source font file and the target font number, each Chinese character is treated as a picture for processing, and it does not rely on early preprocessing and later stroke reorganization. It is an end-to-end Chinese character font migration method, which greatly simplifies the font generation process and enhances the generation effect, and realizes the conversion between printed fonts and between printed fonts and handwritten fonts. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0029] Figure 1 It is a flow chart of the Chinese font generation method based on the nested encoding-decoding network of the present invention;
[0030] Figure 2 It is a schematic diagram of the structure of the nested encoder-decoder network;
[0031] Figure 3 This is a schematic diagram of the structure of the Chinese character migration module;
[0032] Figure 4 The workflow diagram of the nested encoder-decoder network;
[0033] Figure 5 This is the effect diagram of migrating Songti font to the target font;
[0034] Figure 6 It is a module structure diagram of the Chinese font generation system based on the nested encoding-decoding network of the present invention.
[0035] Explanation of symbols:
[0036] Chinese character migration module-1, encoder-11, category font embedding module-12, decoder-13, discriminator module-2, sample acquisition unit-4, training unit-5, font generation unit-6. DETAILED DESCRIPTION
[0037] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0038] The purpose of the present invention is to provide a Chinese font generation method and system based on a nested encoder-decoder network. By constructing a nested encoder-decoder network, the nested encoder-decoder network is trained using some target characters and corresponding source characters to obtain a font generation model. Based on the font generation model, a complete target font file is generated according to the complete source font file and the target font number. Each Chinese character is treated as a picture and is not dependent on the early preprocessing and the later stroke reorganization. It is an end-to-end Chinese character font migration method, which greatly simplifies the font generation process and enhances the generation effect, and realizes the conversion between printed fonts and between printed fonts and handwritten fonts.
[0039] The present invention uses a new nested encoding-decoding network structure for multi-level feature extraction and fusion to better handle the clarity and stroke details of the font. The adversarial learning method is introduced. The adversarial learning method can enable the model to learn pseudo images with the same distribution as the given images, thereby improving the fidelity of the generated target font.
[0040] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the present invention is further described in detail below with reference to the accompanying drawings and specific embodiments.
[0041] like Figure 1 As shown, the Chinese font generation method based on the nested encoding-decoding network of the present invention includes:
[0042] S1: Obtain a training sample set. The training sample set includes a source font sample file, a target font sample file and a target font number; the target font sample file includes some target characters; the source font sample file includes source characters corresponding to the target characters in the target font sample file. In this embodiment, the source font sample file FontR is a Songti ttf file. The target font sample file FontT l is the target printing font ttf or otf file. l represents the corresponding target printing font number, l∈[0,40). Specifically, the number of target characters is N.
[0043] S2: According to the training sample set, the nested encoder-decoder network is trained to obtain a font generation model.
[0044] S3: Based on the font generation model, a complete target font file is generated according to the complete source font file and the target font number.
[0045] Specifically, Figure 2 As shown, the nested encoding-decoding network includes a Chinese character migration module and a discriminator module.
[0046] Step S2 specifically includes:
[0047] S21: Generate a source font image domain according to the source font sample file and generate a target font image domain according to the target font sample file.
[0048] S22: convert the source font image domain R into a source binary text image Ri; convert the target font image domain T l Convert to target binary text image T l Specifically, the source binary text image Ri and the target binary text image T l The image pixels are all 256*256, i∈[0,N). The corresponding source binary text image Ri and target binary text image T l Package them together and generate training set files and test set files with a file size ratio of 4:1.
[0049] S23: Determine the target font category data according to the target font number and the pre-set lookup table. Specifically, the lookup table is a two-dimensional table, the first dimension is the font number, and the second dimension is the font category data; the font category data is a pre-designed font feature. Specifically, the target font number l is encoded into a vector with a dimension of [1,128] as the target font category data CE_l through a pre-set lookup table, and its dimension is converted to [16,16,128] through a broadcast mechanism and dimensional expansion. The pre-set lookup table is generated by non-trainable Gaussian noise, and the dimension is [40,128].
[0050] S24: Using the Chinese character migration module to perform feature fusion on the source binary text image and the target font category data to obtain a feature fusion image.
[0051] S25: Using the discriminator module to discriminate the authenticity of the feature fusion image and the accuracy of the font category. fuse i and the source binary text image Ri are input into the discriminator module D. The discriminator module D includes the authenticity discriminator D B and accuracy discriminator D C . D B It consists of 1 convolution layer and 3 convolution, normalization, and LeakyRelu activation layers, with an output dimension of [16*16*512]. C In D B Based on , a fully connected layer is added at the end, and the output dimension is:
[128] . Before entering the discriminator module, the feature fusion image S fusei The corresponding source binary text image Ri is concatenated in the second dimension to obtain the first discriminant data, which is input into the discriminator module D. First, the authenticity discriminator D B, the first discriminant data is mapped into mapping data D with a dimension of [16*16*512] B i, used to determine the feature fusion image S fuse The authenticity of i. Secondly, the accuracy discriminator D C Generate the second discrimination data D C i, with a dimension of
[128] , is used to determine the accuracy of the generated target printing font type.
[0052] S26: Determine the loss function of the Chinese character migration module according to the target binary text image, the source binary text image, the feature fusion image and the authenticity and accuracy of the feature fusion image.
[0053] S27: Determine the loss function of the discriminator module according to the authenticity of the feature fusion image and the accuracy of the font category.
[0054] S28: Iteratively train the Chinese character migration module according to the loss function of the Chinese character migration module, and iteratively train the discriminator module according to the loss function of the discriminator module, until the loss functions of the Chinese character migration module and the discriminator module converge, so as to obtain an optimal nested encoder-decoder network, and the optimal nested encoder-decoder network is a font generation model. Specifically, iterative optimization is performed through back propagation.
[0055] Furthermore, the Chinese character migration module includes an encoder, a category font embedding module and a decoder which are connected in sequence.
[0056] Step S24: using the Chinese character migration module to perform feature fusion on the source binary text image and the target font category data to obtain a feature fusion image, specifically including:
[0057] S241: Encode the source binary text image using the encoder to obtain source font features.
[0058] S242: Using the category font embedding module to merge the source font features with the target font category data to obtain a category font identification vector.
[0059] Specifically, the source font feature En6Output is passed through a bilinear upsampling layer and then concatenated with the target font category data CE_l in the second dimension to obtain a category font identification vector EmbeddingOutput with a dimension of [16, 16, 640]. The category font embedding module converts the source font feature En6Output and the target font number l into a category font identification vector EmbeddingOutput with a category font identification;
[0060] Before passing through the decoder, non-trainable Gaussian noise is connected as a font category embedding to the source font feature En6Output to solve the problem of multiple font forms for a single character. On the one hand, the encoder part can still map the same character to the same vector; on the other hand, the decoder will also use both character and category font embeddings to generate target data.
[0061] S243: Using the decoder to decode the category font identification vector to obtain a feature fusion image.
[0062] Furthermore, the encoder includes a first nested encoding layer En1, a second nested encoding layer En2, a third nested encoding layer En3, a fourth nested encoding layer En4, a fifth nested encoding layer En5 and a sixth nested encoding layer En6 which are connected in sequence.
[0063] like Figure 3 As shown, step S241 specifically includes:
[0064] The source binary text image is converted into a first encoding feature En1Output using a first nested encoding layer En1.
[0065] The first encoding feature En1Output is converted into a second encoding feature En2Output using a second nested encoding layer En2.
[0066] The second encoding feature En2Output is converted into a third encoding feature En3Output using a third nested encoding layer En3.
[0067] The third encoding feature En3Output is converted into a fourth encoding feature En4Output using a fourth nested encoding layer En4.
[0068] The fourth encoding feature En4Output is converted into a fifth encoding feature En5Output using a fifth nested encoding layer En5.
[0069] The fifth encoding feature En5Output is converted into a source font feature En6Output using a sixth nested encoding layer En6.
[0070] Specifically, the first nested coding layer, the second nested coding layer, the third nested coding layer, the fourth nested coding layer, the fifth nested coding layer, and the sixth nested coding layer all include a convolution-batch normalization-linear rectification function CBR sub-module, a 1 / 2 downsampling DownCBR sub-module, an M-fold expansion M*DilationCBR sub-module and a 2UpCBR sub-module.
[0071] Among them, the CBR submodule includes a first two-dimensional convolution layer, a normalization processing layer and a RELU activation layer, which are connected in sequence with a convolution kernel size of 3, a padding of 1, and a spacing of 1 between convolution kernels.
[0072] The 1 / 2DownCBR submodule includes a two-dimensional maximum pooling layer with a convolution kernel size of 2 and a stride of 2 and a CBR submodule connected in sequence.
[0073] The M*DilationCBR submodule includes a second two-dimensional convolutional layer with a convolution kernel size of 3, a padding of 1, and a spacing of 2 between convolution kernels, a normalization processing layer, and a RELU activation layer.
[0074] The 2UpCBR submodule consists of a bilinear upsampling layer and a CBR module connected sequentially.
[0075] Specifically, the first nested encoding layer En1 converts the source binary text image into a first encoding feature En1Output, specifically including:
[0076] Convert the source binary text image Ri into a vector of dimension [256,256,1], where the 0th and 1st dimensions represent the pixel size, and the 2nd dimension represents the number of channels. The vector is obtained by the CBR module to obtain En1_en1, with a dimension of [256,256,64]; En1_en1 is obtained by the CBR module to obtain En1_en2, with a dimension of [256,256,32]; En1_en2 is obtained by the 1 / 2DownCBR module to obtain En1_en3, with a dimension of [128,128,32]; En1_en3 is obtained by the 1 / 2DownCBR module to obtain En1_en4, with a dimension of [64,64,32]; En1_en 4 En1_en5 is obtained through the 1 / 2DownCBR module, and the dimension is: [32, 32, 32]; En1_en5 is obtained through the 1 / 2DownCBR module to obtain En1_en6, and the dimension is: [16, 16, 32]; En1_en6 is obtained through the 1 / 2DownCBR module to obtain En1_en7, and the dimension is: [8, 8, 32]; En1_en7 is obtained through the 2*DilationCBR module to obtain En1_en8, and the dimension is: [8, 8, 32]. En1_en7 and En1_en8 perform concatenation in the second dimension (joining the new vector to the original vector, corresponding to an increase in the dimension) and obtain En1_de6 through the CBR module, with a dimension of [8,8,32]; En1_en6 and En1_de6 perform concatenation in the second dimension and obtain En1_de5 through the 2UpCBR module, with a dimension of [16,16,32]; En1_en5 and En1_de5 perform concatenation in the second dimension and obtain En1_de4 through the 2UpCBR module, with a dimension of [32,32,32]; En1_en4 and En1_de4 perform concatenation in the second dimension and obtain En1_de5 through the 2UpCBR module, with a dimension of [32,32,32]; Concatenate operation is performed and the 2UpCBR module is used to obtain En1_de3, with a dimension of [64, 64, 32]; En1_en3 and En1_de3 are concatenated in the second dimension and the 2UpCBR module is used to obtain En1_de2, with a dimension of [128, 128, 32]; En1_en2 and En1_de2 are concatenated in the second dimension and the 2UpCBR module is used to obtain En1_de1, with a dimension of [256, 256, 64]; En1_en1 and En1_de1 are added to obtain the first encoding feature En1Output, with a dimension of [256, 256, 64].
[0077] The first nested encoding layer En1 converts the input data into an intermediate map En1_en1 with the same number of channels as the output and performs local feature extraction; a symmetric encoding and decoding structure with a definition parameter of 7 is adopted - 7 represents the number of hierarchical sampling times, and the intermediate map En1_en1 is used as input. Multi-scale features are extracted in the process of gradual downsampling, and encoded into high-resolution feature data through progressive upsampling, connection and convolution operations. This process reduces the loss of fine details caused by large-scale direct upsampling, thereby realizing multi-level feature extraction within the encoding and decoding structure, and also makes the network deeper, obtains a larger receptive field and richer local and global features, and learns to extract and encode multi-scale semantic information; the first encoding feature En1Output is obtained by adding En1_en1 and En1_de1 to sum and fuse local features and multi-scale features.
[0078] The structure of the second nested coding layer En2 is similar to that of the first nested coding layer En1, and also includes a CBR submodule, a 1 / 2DownCBR submodule, an M*DilationCBR submodule, and a 2UpCBR submodule.
[0079] The second nested coding layer En2 converts the first coding feature En1Output into the second coding feature En2Output, specifically including: the first coding feature En1Output is passed through a two-dimensional maximum pooling layer composed of a convolution kernel size of 2 and a step size of 2 to obtain data En2Input with a dimension of [128, 128, 64]. En2Input is input into the second nested coding layer En2: En2Input is passed through the CBR module to obtain En2_en1 with a dimension of [128, 128, 128]; En2_en1 is passed through the CBR module to obtain En2_en2 with a dimension of [128, 128, 32]; En2_en2 is passed through the 1 / 2DownCBR module to obtain En2_en3 with a dimension of [64, 64, 32]; En2_en3 is passed through the 1 / 2DownCBR module to obtain En2_en4 with a dimension of [64, 64, 32]. The dimension is [32,32,32]; En2_en4 is obtained by 1 / 2DownCBR module to obtain En2_en5, and the dimension is [16,16,32]; En2_en5 is obtained by 1 / 2DownCBR module to obtain En2_en6, and the dimension is [8,8,32]; En2_en6 is obtained by 2*DilationCBR module to obtain En2_en7, and the dimension is [8,8,32]; En2_en6 and En2_en7 are concatenated in the second dimension And through the CBR module, En2_de5 is obtained, and the dimension is: [8,8,32]; En2_en5 and En2_de5 are concatenated in the second dimension and the 2UpCBR module is used to obtain En2_de4, and the dimension is: [16,16,32]; En2_en4 and En2_de4 are concatenated in the second dimension and the 2UpCBR module is used to obtain En2_de3, and the dimension is: [32,32,32]; En2_en3 and En2_de 3. Concatenate operation is performed in the second dimension and the 2UpCBR module is used to obtain En2_de2 with a dimension of [64, 64, 32]. Concatenate operation is performed on En2_en2 and En2_de2 in the second dimension and the 2UpCBR module is used to obtain En2_de1 with a dimension of [128, 128, 128]. Addition operation is performed on En2_en1 and En2_de1 to obtain the second encoding feature En2Output with a dimension of [128, 128, 128].
[0080] The second nested encoding layer En2 converts the input data En2Input into an intermediate map En2_en1 with the same number of channels as the output and performs local feature extraction. A symmetric encoding and decoding structure with a definition parameter of 6 is adopted, and the intermediate map En2_en1 is used as input. Multi-scale features are extracted in the process of step-by-step downsampling, and encoded into high-resolution feature data through progressive upsampling, connection and convolution operations. This process reduces the loss of fine details caused by large-scale direct upsampling, thereby realizing multi-level feature extraction within the encoding and decoding structure, and also makes the network deeper, obtains a larger receptive field and richer local and global features, and learns to extract and encode multi-scale semantic information; the second encoding feature En2Output is obtained by adding En2_en1 and En2_de1 to sum and fuse local features and multi-scale features.
[0081] The structure of the third nested coding layer En3 is similar to that of the first nested coding layer En1, and also includes a CBR submodule, a 1 / 2DownCBR submodule, an M*DilationCBR submodule, and a 2UpCBR submodule.
[0082] The third nested encoding layer En3 converts the second encoding feature En2Output into a third encoding feature En3Output, specifically including:
[0083] The second encoded feature En2Output is passed through a two-dimensional maximum pooling layer consisting of a convolution kernel size of 2 and a step size of 2 to obtain data En3Input with a dimension of [64, 64, 128]. En3Input is input into the third nested encoding layer En3 - En3Input passes through the CBR module to obtain En3_en1, with a dimension of [64, 64, 256]; En3_en1 passes through the CBR module to En3_en2, with a dimension of [64, 64, 64]; En3_en2 passes through the 1 / 2DownCBR module to obtain En3_en3, with a dimension of [32, 32, 64]; En3_en3 passes through the 1 / 2DownCBR module to obtain En3_en4, with a dimension of [16, 16, 64]; En3_en4 passes through the 1 / 2DownCBR module to obtain En3_en5, with a dimension of [8, 8, 64]; En3_en5 passes through the 2*DilationCBR module to obtain En3_en6, with a dimension of [8, 8, 64]; En3_en5 and En3_en6 are processed in the second dimension Concatenate operation and pass the CBR module to obtain En3_de4, the dimension is: [8,8,64]; En3_en4 and En3_de4 are concatenated in the second dimension and the 2UpCBR module is used to obtain En3_de3, the dimension is: [16,16,64]; En3_en3 and En3_de3 are concatenated in the second dimension and the 2UpCBR module is used to obtain En2_de2, the dimension is: [32,32,64]; En3_en2 and En3_de2 are concatenated in the second dimension and the 2UpCBR module is used to obtain En3_de1, the dimension is: [64,64,256]; En3_en1 and En3_de1 are added to obtain the third encoding feature En3Output, the dimension is: [64,64,256].
[0084] The third nested encoding layer En3 converts the input data En3Input into an intermediate map En3_en1 with the same number of channels as the output and performs local feature extraction. A symmetric encoding and decoding structure with a definition parameter of 5 is adopted, and the intermediate map En3_en1 is used as input. Multi-scale features are extracted in the process of step-by-step downsampling, and encoded into high-resolution feature data through progressive upsampling, connection and convolution operations. This process reduces the loss of fine details caused by large-scale direct upsampling, thereby realizing multi-level feature extraction within the encoding and decoding structure, and also makes the network deeper, obtains a larger receptive field and richer local and global features, and learns to extract and encode multi-scale semantic information; the third encoding feature En3Output is obtained by adding En3_en1 and En3_de1 to sum and fuse local features and multi-scale features.
[0085] The structure of the fourth nested coding layer En4 is similar to that of the first nested coding layer En1, and also includes a CBR submodule, a 1 / 2DownCBR submodule, an M*DilationCBR submodule, and a 2UpCBR submodule.
[0086] The fourth nested encoding layer En4 converts the third encoding feature En3Output into a fourth encoding feature En4Output, specifically including:
[0087] The third encoding feature En3Output is passed through a two-dimensional maximum pooling layer consisting of a convolution kernel size of 2 and a stride of 2 to obtain data En4Input with a dimension of [32,32,256]. En4Input is input into the fourth nested encoding layer En4 - En4Input passes through the CBR module to obtain En4_en1, with a dimension of [32,32,512]; En4_en1 passes through the CBR module to En4_en2, with a dimension of [32,32,128]; En4_en2 passes through the 1 / 2DownCBR module to obtain En4_en3, with a dimension of [16,16,128]; En4_en3 passes through the 1 / 2DownCBR module to obtain En4_en4, with a dimension of [8,8,128]; En4_en4 passes through the 2*DilationCBR module to obtain En4_en5, with a dimension of [8,8,128]; En4_en4 and En4_en5 is concatenated in the second dimension and passed through the CBR module to obtain En4_de3, with a dimension of [8, 8, 128]; En4_en3 and En4_de3 are concatenated in the second dimension and passed through the 2UpCBR module to obtain En4_de2, with a dimension of [16, 16, 128]; En4_en2 and En4_de2 are concatenated in the second dimension and passed through the 2UpCBR module to obtain En4_de1, with a dimension of [32, 32, 512]; En4_en1 and En4_de1 are added to obtain the fourth encoding feature En4Output, with a dimension of [32, 32, 512].
[0088] The fourth nested encoding layer En4 converts the input data En4Input into an intermediate map En4_en1 with the same number of channels as the output and performs local feature extraction; a symmetric encoding and decoding structure with a definition parameter of 4 is adopted, and the intermediate map En4_en1 is used as input. Multi-scale features are extracted in the process of gradual downsampling, and encoded into high-resolution feature data through progressive upsampling, connection and convolution operations. This process reduces the loss of fine details caused by large-scale direct upsampling, thereby realizing multi-level feature extraction within the encoding and decoding structure, and also makes the network deeper, obtains a larger receptive field and richer local and global features, and learns to extract and encode multi-scale semantic information; the fourth encoding feature En4Output is obtained by adding En4_en1 and En4_de1 to sum and fuse local features and multi-scale features.
[0089] The structure of the fifth nested coding layer En5 is similar to that of the first nested coding layer En1, and also includes a CBR submodule, a 1 / 2DownCBR submodule, an M*DilationCBR submodule, and a 2UpCBR submodule.
[0090] The fifth nested encoding layer En5 converts the fourth encoding feature En4Output into a fifth encoding feature En5Output, specifically including:
[0091] The fourth encoding feature En4Output is passed through a two-dimensional maximum pooling layer consisting of a convolution kernel size of 2 and a stride of 2 to obtain data En5Input with a dimension of [16, 16, 512]. En5Input is input into the fifth nested encoding layer En5 - En5Input passes through the CBR module to obtain En5_en1, with a dimension of [16, 16, 512]; En5_en1 passes through the CBR module to En5_en2, with a dimension of [16, 16, 256]; En5_en2 passes through the 2*DilationCBR module to obtain En5_en3, with a dimension of [16, 16, 256]; En5_en3 passes through the 4*DilationCBR module to obtain En5_en4, with a dimension of [16, 16, 256]; En5_en4 passes through the 8*DilationCBR module to obtain En5_en5, with a dimension of [16, 16, 256]; En5_en4 and En5 _en5 performs concatenation operation in the second dimension and obtains En5_de3 through the 4*DilationCBR module, with a dimension of [16, 16, 256]; En5_en3 and En5_de3 perform concatenation operation in the second dimension and obtain En5_de2 through the 2*DilationCBR module, with a dimension of [16, 16, 256]; En5_en2 and En5_de2 perform concatenation operation in the second dimension and obtain En5_de1 through the CBR module, with a dimension of [16, 16, 512]; En5_en1 and En5_de1 perform addition operation to obtain the fifth encoding feature En5Output, with a dimension of [16, 16, 512].
[0092] The fifth nested encoding layer En5 converts the input data En5Input into an intermediate map En5_en1 with the same number of channels as the output and performs local feature extraction. A symmetric encoding and decoding structure with a height of 4 is used, and the intermediate map En5_en1 is used as input. The 0th and 1st dimensions of the data En5_en1 represent the resolution of the data. Because the resolution of the data is relatively low, further reducing the resolution for sampling will lead to the loss of useful context. Therefore, the extended convolution is used to replace the pooling and upsampling operations, so that the data inside the En5 module has the same resolution as the input data En5Input, extracting and learning multi-scale semantic information.
[0093] The structure of the sixth nested coding layer En6 is similar to that of the first nested coding layer En1, and also includes a CBR submodule, a 1 / 2DownCBR submodule, an M*DilationCBR submodule, and a 2UpCBR submodule.
[0094] The sixth nested encoding layer En6 converts the fifth encoding feature En6Output into a source font feature En6Output, specifically including:
[0095] The fifth encoding feature En5Output is passed through a two-dimensional maximum pooling layer consisting of a convolution kernel size of 2 and a stride of 2 to obtain data En6Input with a dimension of [8,8,512]. En6Input is input into the sixth nested encoding layer En6 - En6Input is passed through the CBR module to obtain En6_en1, with a dimension of [8,8,512]; En6_en1 is passed through the CBR module to En6_en2, with a dimension of [8,8,256]; En6_en2 is passed through the 2*DilationCBR module to obtain En6_en3, with a dimension of [8,8,256]; En6_en3 is passed through the 4*DilationCBR module to obtain En6_en4, with a dimension of [8,8,256]; En6_en4 is passed through the 8*DilationCBR module to obtain En6_en5, with a dimension of [8,8,256]; En6_en4 and En6 _en5 is concatenated in the second dimension and passed through the 4*DilationCBR module to obtain En6_de3, with a dimension of [8,8,256]; En5_en3 and En6_de3 are concatenated in the second dimension and passed through the 2*DilationCBR module to obtain En6_de2, with a dimension of [8,8,256]; En6_en2 and En6_de2 are concatenated in the second dimension and passed through the CBR module to obtain En6_de1, with a dimension of [8,8,512]; En6_en1 and En6_de1 are added to obtain the source font feature En6Output, with a dimension of [8,8,512].
[0096] The sixth nested encoding layer En6 converts the input data En6Input into an intermediate map En6_en1 with the same number of channels as the output and performs local feature extraction; a symmetric encoding and decoding structure with a height of 4 is used, and the intermediate map En6_en1 is used as input. The 0th and 1st dimensions of the data En6_en1 represent the resolution of the data. Because the resolution of the data is relatively low, further reducing the resolution for sampling will lead to the loss of useful context. Therefore, we use dilated convolution to replace pooling and upsampling operations, so that the data inside the En6 module has the same resolution as the input data En6Input, extracting and learning multi-scale semantic information.
[0097] Furthermore, the decoder includes a fifth nested decoding layer, a fourth nested decoding layer, a third nested decoding layer, a second nested decoding layer and a first nested decoding layer connected in sequence; the first nested decoding layer is also connected to the first nested encoding layer; the second nested decoding layer is also connected to the second nested encoding layer; the third nested decoding layer is also connected to the third nested encoding layer; the fourth nested decoding layer is also connected to the fourth nested encoding layer; the fifth nested decoding layer is also connected to the category font embedding module.
[0098] Step S243: using the decoder to decode the category font identification vector to obtain a feature fusion image, specifically including:
[0099] The fifth nested decoding layer is used to connect the category font identification vector and the fifth encoding feature and convert them into the fifth decoding feature. The structure of the fifth nested decoding layer De5 is consistent with the structure of the fifth nested encoding layer En5.
[0100] Specifically, the fifth encoding feature En5Output and the category font identification vector EmbeddingOutput are concatenated in the second dimension and passed through a bilinear upsampling layer to obtain data De5Input with a dimension of [16, 16, 1152]. De5Input is input into the fifth nested decoding layer De5 to obtain the fifth decoding feature De5Output with a dimension of [16, 16, 512]. The fifth nested decoding layer De5 converts the input data De5Input into an intermediate map De5_en1 with the same number of channels as the output and performs local feature extraction; a symmetric encoding and decoding structure with a height of 4 is used, and the intermediate map De5_en1 is used as input. The 0th and 1st dimensions of the data De5_en1 represent the resolution of the data. Because the resolution of the data is relatively low, further reducing the resolution for sampling will result in the loss of useful context. Therefore, an extended convolution is used to replace the pooling and upsampling operations, so that the data inside the fifth nested decoding layer De5 has the same resolution as the input data De5Input, and extracts and learns multi-scale semantic information.
[0101] The fourth nested decoding layer is used to connect the fifth decoding feature and the fourth encoding feature and convert them into a fourth decoding feature. The structure of the fourth nested decoding layer De4 is consistent with the structure of the fourth nested encoding layer En4.
[0102] Specifically, the fourth encoding feature En4Output and the fifth decoding feature De5Output are concatenated in the second dimension and passed through a bilinear upsampling layer to obtain data De4Input with a dimension of [32, 32, 1024]. De4Input is input into the fourth nested decoding layer De4 to obtain the fourth decoding feature De4Output with a dimension of [32, 32, 256]. The fourth nested decoding layer De4 converts the input data De4Input into an intermediate map De4_en1 with the same number of channels as the output and performs local feature extraction; a symmetric encoding and decoding structure with a definition parameter of 4 is adopted, and the intermediate map De4_en1 is used as input. Multi-scale features are extracted in the process of gradual downsampling, and encoded into high-resolution feature data through progressive upsampling, connection and convolution operations. This process reduces the loss of fine details caused by large-scale direct upsampling, thereby realizing multi-level feature extraction within the encoding and decoding structure, and also makes the network deeper, obtains a larger receptive field and richer local and global features, and learns to extract and encode multi-scale semantic information; the fourth decoding feature De4Output is obtained by adding De4_en1 and De4_de1 to sum and fuse local features and multi-scale features.
[0103] The fourth decoding feature and the third encoding feature are connected and converted into a third decoding feature using the third nested decoding layer. The structure of the third nested decoding layer De3 is consistent with the structure of the third nested encoding layer En3.
[0104] Specifically, the third encoding feature En3Output and the fourth decoding feature De4Output are concatenated in the second dimension and passed through a bilinear upsampling layer to obtain data De3Input with a dimension of [64, 64, 512]. De3Input is input into the third nested decoding layer De3 to obtain the third decoding feature De3Output with a dimension of [64, 64, 128]. The third nested decoding layer De3 converts the input data De3Input into an intermediate map De3_en1 with the same number of channels as the output and performs local feature extraction; a symmetric encoding and decoding structure with a definition parameter of 5 is adopted, and the intermediate map De3_en1 is used as input. Multi-scale features are extracted in the process of gradual downsampling, and encoded into high-resolution feature data through progressive upsampling, connection and convolution operations. This process reduces the loss of fine details caused by large-scale direct upsampling, thereby realizing multi-level feature extraction within the encoding and decoding structure, and also makes the network deeper, obtains a larger receptive field and richer local and global features, and learns to extract and encode multi-scale semantic information; the third decoding feature De3Output is obtained by adding De3_en1 and De3_de1 to sum and fuse local features and multi-scale features.
[0105] The second nested decoding layer is used to connect the third decoding feature and the second encoding feature and convert them into a second decoding feature. The structure of the second nested decoding layer De2 is consistent with the structure of the second nested encoding layer En2.
[0106] Specifically, the second encoding feature En2Output and the third decoding feature De3Output are concatenated in the second dimension and passed through a bilinear upsampling layer to obtain input data De2Input of dimension [128, 128, 256]. De2Input is input into the second nested decoding layer De2 to obtain the second decoding feature De2Output of dimension [128, 128, 64]. The second nested decoding layer De2 converts the input data De2Input into an intermediate map De2_en1 with the same number of channels as the output and performs local feature extraction; a symmetric encoding and decoding structure with a definition parameter of 6 is adopted, and the intermediate map De2_en1 is used as input. Multi-scale features are extracted in the process of gradual downsampling, and encoded into high-resolution feature data through progressive upsampling, connection and convolution operations. This process reduces the loss of fine details caused by large-scale direct upsampling, thereby realizing multi-level feature extraction within the encoding and decoding structure, and also makes the network deeper, obtains a larger receptive field and richer local and global features, and learns to extract and encode multi-scale semantic information; the second decoding feature De2Output is obtained by adding De2_en1 and De2_de1 to sum and fuse local features and multi-scale features.
[0107] The first nested decoding layer is used to connect the second decoding feature and the first encoding feature and convert them into the first decoding feature. The structure of the first nested decoding layer De1 is consistent with the structure of the first nested encoding layer En1.
[0108] Specifically, the first encoding feature En1Output and the second decoding feature De2Output are concatenated in the second dimension and the bilinear upsampling layer is used to obtain the input data De1Input with a dimension of [256, 256, 128]. De1Input is input into the first nested decoding De1 to obtain the first decoding feature De1Output with a dimension of [256, 256, 64]. The first nested decoding layer De1 converts the input data De1Input into an intermediate map De1_en1 with the same number of channels as the output and performs local feature extraction; a symmetric encoding and decoding structure with a definition parameter of 7 is adopted, and the intermediate map De1_en1 is used as input. Multi-scale features are extracted in the process of gradual downsampling, and encoded into high-resolution feature data through progressive upsampling, connection and convolution operations. This process reduces the loss of fine details caused by large-scale direct upsampling, thereby realizing multi-level feature extraction within the encoding and decoding structure, and also makes the network deeper, obtains a larger receptive field and richer local and global features, and learns to extract and encode multi-scale semantic information; the first decoding feature De1Output is obtained by adding De1_en1 and De1_de1 to sum and fuse local features and multi-scale features.
[0109] A sixth local feature map is obtained according to the source font feature.
[0110] A fifth local feature map is obtained according to the fifth decoding feature.
[0111] A fourth local feature map is obtained according to the fourth decoding feature.
[0112] A third local feature map is obtained according to the third decoding feature.
[0113] A second local feature map is obtained according to the second decoding feature.
[0114] A first local feature map is obtained according to the first decoding feature.
[0115] Specifically, the source font feature En6Output, the fifth decoding feature De5Output, the fourth decoding feature De4Output, the third decoding feature De3Output, the second decoding feature De2Output, and the first decoding feature De1Output are all processed through a two-dimensional convolution layer with a convolution kernel of 3*3 and a Sigmoid function to obtain the corresponding local feature map: the sixth local feature map The dimension is: [8,8,1], the fifth local feature map The dimension is: [16,16,1], the fourth local feature map The dimension is: [32,32,1], the third local feature map The dimension is: [64,64,1], the second local feature map The dimension is: [128, 128, 1], the first local feature map The dimensions are: [256, 256, 1].
[0116] The sixth local feature map, the fifth local feature map, the fourth local feature map, the third local feature map, the second local feature map and the first local feature map are fused to obtain a feature fused image.
[0117] Specifically, the sixth local feature map, the fifth local feature map, the fourth local feature map, the third local feature map, the second local feature map and the first local feature map are respectively upsampled by a bilinear layer to a dimension of [256, 256, 1] and their second dimensions are concatenated, and then a 1*1 two-dimensional convolution layer and a Sigmoid function are used to generate a feature fusion image S fuse i, dimension is [256,256,1]. Figure 4 Shown is a flowchart of the nested encoding-decoding network of the present invention.
[0118] Each nested structure in the nested encoding-decoding network structure of the present invention can more effectively extract the multi-scale features of the input data and the multi-level features of the aggregation stage, and better handle the clarity and stroke detail issues of the font.
[0119] The present invention introduces an adversarial learning method, so that the model learns pseudo images with the same distribution as the given images, thereby improving the fidelity of the generated target font.
[0120] Furthermore, the Chinese character migration module loss function G loss It consists of four loss functions.
[0121] (1) Total feature map loss function During training, the source binary text image Ri and the target binary text image T l i, two pairs; the local feature map mapped by the i-th source binary text image Ri through the Chinese character migration module After upsampling to the target font image size, it is compared with the target binary text image T l i constitutes the local feature map loss function
[0122]
[0123] in, is the local feature map loss function, the superscript m indicates the number of local feature maps, (r, c) is the pixel coordinate, and (H, W) is the pixel coordinate after upsampling to the target font image size. The height and width of the image, Represents the target binary text image T l The characteristic value of pixel i, P Ri(r,c) Represents the feature value of the pixel point Ri of the source binary text image, and the total feature map loss function is
[0124]
[0125] in is the total feature map loss function, is the local feature map loss function; YesS fuse The loss function of the fused feature map is as follows: Consistent; M=6. The function of the total feature map loss function is to calculate the loss caused by upsampling the local feature map and fusion of the feature map, and to use it for back propagation to reduce the loss. The training process begins by minimizing the overall loss so that the output feature fusion image can better handle the strokes of the text.
[0126] (2) Minimum absolute deviation loss function L1. The target binary text image T l i and feature fusion image S fuse Input to L1:
[0127]
[0128] Among them, (r, c) is the pixel coordinate of the feature fusion image, (H, W) is the height and width of the feature fusion image, T l i is the target binary text image, is the target binary text image T l The characteristic value of pixel i, S fuse i is the feature fusion image, is the feature fusion image S fuse The feature value of the pixel point i. The minimum absolute value deviation loss function L1 is used to determine the feature fusion image S fuse i and target binary text image T l The absolute value deviation of i.
[0129] (3) Category loss function L cat During training, the target font category data CE_1 generated in step S23 is compared with the second discrimination data D obtained in step S25. C i input to L cat middle:
[0130] L cat is the known CrossEntropyLoss function, DC i is the first parameter and CE_l is the second parameter.
[0131] Category loss function L cat Used to calculate the feature fusion image S fuse The smaller the font number i is, the closer it is to the target font category data CE_1.
[0132] (4) Encoding constant loss function L EnCo : During training, the source binary text image Ri is combined with the feature fusion image S fuse i pairing, through the Chinese character encoding module E to form the encoding constant loss function L EnCo :
[0133]
[0134] Among them, E is the Chinese character encoding network, E(Ri) is the code composed of the source binary text image Ri; E(S fuse i) is the feature fusion image S fuse The encoding of i; S fuse i is the feature fusion image; N is the number of target characters. Encoding constant loss function L EnCo Used to measure the difference between two input data.
[0135] (5) Discriminant loss function L DF : During training, the mapping data D obtained in step S25 is B i input to L DF middle:
[0136] L DF is the known BCEWithLogitsLoss function, D B i is the first parameter, and D B The second parameter is a vector with all internal values of 1 in the same i dimension. DF It is used to control the discriminator's ability to make misjudgments. The smaller the value, the stronger the ability, thereby improving the generator's generation ability.
[0137] Therefore, the loss function G of the Chinese character migration module is loss :
[0138]
[0139] Among them, the hyperparameters are: Net pen =10, L1 pen =100, Cat pen 1. EnCo pen is 15, is the total feature map loss function, L1 is the minimum absolute deviation loss function, Lcat is the category loss function, L EnCo To encode a constant loss function, L DF is the discriminant loss function.
[0140] The source binary text image Ri and the target binary text image T l After i is converted into a vector, a Concatenate operation is performed in the second dimension to obtain the real data real_ab. Source binary text image Ri and feature fusion image S fuse After i is converted into a vector, a Concatenate operation is performed in the second dimension to obtain the fake data fake_ab. The real data real_ab and the fake data fake_ab are input into the discriminator D respectively to obtain the real mapping data D B real_ab and real discriminant data D C real_ab, false mapping data D B fake_ab and false discriminant data D C fake_ab.
[0141] The loss function D of the discriminator module loss It consists of two types of loss functions:
[0142] (1) Discriminant loss function L DF : During training, L DF By L DF real and L DF Fake composition. DF real is the known BCEWithLogitsLoss function, D B real_ab is the first parameter, and D B real_ab has the same dimensions, and the second argument is a vector with all internal values 1. DF fake is the known BCEWithLogitsLoss function, D B fake_ab is the first parameter, and D B The second argument of fake_ab is a vector with all 1s in it, with the same dimensions as the first argument.
[0143] L DF =L DF fake+L DF real
[0144] Discriminative loss function L DF It is used to measure the discriminator's ability to identify whether it is a target font image. The smaller the value, the stronger it is.
[0145] (2) Category loss function L cat : During training, Lcat By L cat real and L cat Fake composition. cat real is the known CrossEntropyLoss function, D C real_ab is the first parameter, and D C real_ab has the same dimensions, and the second argument is a vector with all internal values 1. cat fake is the known BCEWithLogitsLoss function, D C fake_ab is the first parameter, and D C The second argument of fake_ab is a vector with all 1s in it, with the same dimensions as the first argument.
[0146] L cat =Cat pen *L cat fake+L cat real
[0147] The hyperparameter Cat pen is 1, the category loss function L cat It is used to measure the discriminator's ability to identify whether it is the target font category. The smaller the value, the stronger it is.
[0148] Therefore, the loss function of the discriminator module is:
[0149]
[0150] Through the discriminator module loss function D loss It can optimize the content of the generated target font image to make its content clearer; it can optimize the font category of the generated target font image to make the generated image similar to the real target font image, and at the same time make the decoding layer retain the font type of the generated Chinese characters, narrowing the searchable range and thus accelerating the convergence speed.
[0151] In this embodiment, after 800 epochs of training, the Chinese character migration module performs well in the test set. Figure 5 As shown, the first line is the source font, the second line is the generated target printing font, and the third line is the target real font. The present invention treats each Chinese character as a picture and does not rely on the early preprocessing and the later stroke reorganization. It is an end-to-end Chinese character font migration system, which greatly simplifies the font generation process and enhances the generation effect.
[0152] like Figure 6 As shown, the Chinese font generation system based on the nested encoding-decoding network of the present invention includes: a sample acquisition unit 4, a training unit 5 and a font generation unit 6.
[0153] The sample acquisition unit 4 is used to acquire a training sample set. The training sample set includes a source font sample file, a target font sample file and a target font number. The target font sample file includes some target characters. The source font sample file includes source characters corresponding to the target characters in the target font sample file.
[0154] The training unit 5 is connected to the sample acquisition unit 4, and the training unit 5 is used to train the nested encoder-decoder network according to the training sample set to obtain a font generation model.
[0155] The font generation unit 6 is connected to the training unit 5, and is used to generate a complete target font file based on the font generation model, according to the complete source font file and the target font number.
[0156] Compared with the prior art, the Chinese font generation system based on the nested encoder-decoder network of the present invention has the same beneficial effects as the Chinese font generation method based on the nested encoder-decoder network, which will not be described in detail here.
[0157] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the system disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.
[0158] The principles and implementation methods of the present invention are described in this article using specific examples. The description of the above embodiments is only used to help understand the method and core idea of the present invention. At the same time, for those skilled in the art, according to the idea of the present invention, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as limiting the present invention.
Claims
1. A Chinese font generation method based on a nested encoder-decoder network, characterized in that: The Chinese font generation method based on the nested encoding-decoding network includes: Acquire a training sample set; the training sample set includes a source font sample file, a target font sample file and a target font number; the target font sample file includes some target characters; the source font sample file includes source characters corresponding to the target characters in the target font sample file; According to the training sample set, a nested encoder-decoder network is trained to obtain a font generation model; the nested encoder-decoder network includes a Chinese character migration module and a discriminator module; The step of training the nested encoder-decoder network according to the training sample set to obtain a font generation model specifically includes: Generate a source font image domain according to the source font sample file; generate a target font image domain according to the target font sample file; Converting the source font image domain into a source binary text image; Converting the target font image domain into a target binary text image; Determine the target font category data according to the target font number and a pre-set lookup table; the lookup table is a two-dimensional table, the first dimension is the font number, and the second dimension is the font category data; the font category data is a pre-designed font feature; Using the Chinese character migration module to perform feature fusion on the source binary text image and the target font category data to obtain a feature fusion image; Using the discriminator module to discriminate the authenticity of the feature fusion image and the accuracy of the font category; Determine the loss function of the Chinese character migration module according to the target binary text image, the source binary text image, the feature fusion image, the authenticity of the feature fusion image and the accuracy of the font category; Determining a loss function of the discriminator module according to the authenticity of the feature fusion image and the accuracy of the font category; Iteratively training the Chinese character migration module according to the loss function of the Chinese character migration module, and iteratively training the discriminator module according to the loss function of the discriminator module, until the loss functions of the Chinese character migration module and the discriminator module converge, so as to obtain an optimal nested encoder-decoder network, and the optimal nested encoder-decoder network is a font generation model; Based on the font generation model, a complete target font file is generated according to the complete source font file and the target font number.
2. The Chinese font generation method based on the nested encoding-decoding network according to claim 1, characterized in that: The Chinese character migration module includes an encoder, a category font embedding module and a decoder connected in sequence; The Chinese character migration module is used to perform feature fusion on the source binary text image and the target font category data to obtain a feature fusion image, specifically including: Encoding the source binary text image using the encoder to obtain source font features; Using the category font embedding module to merge the source font features with the target font category data to obtain a category font identification vector; The decoder is used to decode the category font identification vector to obtain a feature fusion image.
3. The Chinese font generation method based on nested encoding-decoding network according to claim 2, characterized in that: The encoder comprises a first nested coding layer, a second nested coding layer, a third nested coding layer, a fourth nested coding layer, a fifth nested coding layer and a sixth nested coding layer connected in sequence; The encoding of the source binary text image by the encoder to obtain source font features specifically includes: Using a first nested coding layer to convert the source binary text image into a first coding feature; Using a second nested coding layer to convert the first coding feature into a second coding feature; Using a third nested coding layer to convert the second coding feature into a third coding feature; Using a fourth nested coding layer to convert the third coding feature into a fourth coding feature; Using a fifth nested coding layer to convert the fourth coding feature into a fifth coding feature; The fifth encoding feature is converted into a source font feature using a sixth nested encoding layer.
4. The Chinese font generation method based on nested encoding-decoding network according to claim 3, characterized in that: The decoder comprises a fifth nested decoding layer, a fourth nested decoding layer, a third nested decoding layer, a second nested decoding layer and a first nested decoding layer connected in sequence; the first nested decoding layer is also connected to the first nested coding layer; the second nested decoding layer is also connected to the second nested coding layer; the third nested decoding layer is also connected to the third nested coding layer; the fourth nested decoding layer is also connected to the fourth nested coding layer; the fifth nested decoding layer is also connected to the category font embedding module; The decoding of the category font identification vector by the decoder to obtain a feature fusion image specifically includes: Using the fifth nested decoding layer, the category font identification vector and the fifth encoding feature are connected and converted into a fifth decoding feature; Using the fourth nested decoding layer, the fifth decoding feature and the fourth encoding feature are concatenated and converted into a fourth decoding feature; Using the third nested decoding layer, the fourth decoding feature and the third encoding feature are connected and converted into a third decoding feature; Using the second nested decoding layer, the third decoding feature and the second encoding feature are connected and converted into a second decoding feature; Using the first nested decoding layer, concatenating the second decoding feature and the first encoding feature, and converting them into a first decoding feature; Obtain a sixth local feature map according to the source font feature; Obtain a fifth local feature map according to the fifth decoding feature; Obtaining a fourth local feature map according to the fourth decoding feature; Obtaining a third local feature map according to the third decoding feature; Obtain a second local feature map according to the second decoding feature; Obtaining a first local feature map according to the first decoding feature; The sixth local feature map, the fifth local feature map, the fourth local feature map, the third local feature map, the second local feature map and the first local feature map are fused to obtain a feature fused image.
5. The Chinese font generation method based on nested encoding-decoding network according to claim 1, characterized in that: Determining the loss function of the Chinese character migration module according to the target binary text image, the source binary text image, the feature fusion image, the authenticity of the feature fusion image and the accuracy of the font category specifically includes: Determining a total feature map loss function according to the target binary text image and the feature fusion image; Determining a minimum absolute value deviation loss function according to the target binary text image and the feature fusion image; Determining a category loss function according to the accuracy of the font category and the target font number; Determining a coding constant loss function according to the feature fusion image and the source binary text image; Determining a discrimination loss function according to the feature fusion image and the source binary text image; The loss function of the Chinese character migration module is determined according to the total feature map loss function, the minimum absolute value deviation loss function, the category loss function, the encoding constant loss function and the discrimination loss function.
6. The Chinese font generation method based on nested encoding-decoding network according to claim 5, characterized in that: The loss function of the Chinese character migration module is: Among them, G loss is the loss function of the Chinese character migration module, is the total feature map loss function, L1 is the minimum absolute deviation loss function, L cat is the category loss function, L EnCo To encode a constant loss function, L DF is the discriminant loss function, Net pen 、L1 pen 、Cat pen 、EnCo pen is a hyperparameter.
7. The Chinese font generation method based on nested encoding-decoding network according to claim 5, characterized in that: The total feature map loss function is: in, is the mth local feature map mapped from the i-th source binary text image by the Chinese character migration module, is the loss function of the feature fusion image, M=6.
8. The Chinese font generation method based on nested encoding-decoding network according to claim 5, characterized in that: The minimum absolute deviation loss function is: Among them, (r, c) is the pixel coordinate of the feature fusion image, (H, W) is the height and width of the feature fusion image, T l i is the target binary text image, is the target binary text image T l The characteristic value of pixel i, S fuse i is the feature fusion image, is the feature fusion image S fuse The characteristic value of pixel i.
9. A Chinese font generation system based on a nested encoder-decoder network, applied to the Chinese font generation method based on a nested encoder-decoder network according to any one of claims 1 to 8, characterized in that: The Chinese font generation system based on the nested encoding-decoding network includes: A sample acquisition unit is used to acquire a training sample set; the training sample set includes a source font sample file, a target font sample file and a target font number; the target font sample file includes some target characters; the source font sample file includes source characters corresponding to the target characters in the target font sample file; A training unit, connected to the sample acquisition unit, for training the nested encoder-decoder network according to the training sample set to obtain a font generation model; The font generation unit is connected to the training unit and is used to generate a complete target font file based on the font generation model and according to the complete source font file and the target font number.
