A font generation method, device and equipment

By training a font generation network to decouple the font content and attribute encoding of characters, the problem of high cost of generating new fonts in existing technologies is solved, and the efficient generation of fonts with unique styles is achieved.

CN114386370BActive Publication Date: 2024-11-29BEIJING YOUZHUJU NETWORK TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210043722.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-01-14
Publication Date
2024-11-29
Estimated Expiration
2042-01-14

AI Technical Summary

Technical Problem

In existing technologies, generating new fonts requires designers to spend a lot of time and effort, resulting in high costs and making it impossible to efficiently generate fonts with unique styles.

Method used

By training a font generation network, the font content and attribute encoding of characters are decoupled. Different font attributes in the training samples are used for interpolation to generate new font attributes, thereby generating the target character.

Benefits of technology

It enables the efficient generation of new fonts with unique styles, reduces design costs, and improves font generation efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114386370B_ABST
    Figure CN114386370B_ABST
Patent Text Reader

Abstract

The embodiment of the present application discloses a font generation method. When generating a new font, a fifth character providing font content and a character set providing font attributes are obtained, and the character set includes a sixth character and a seventh character. The font attribute of the sixth character is different from the font attribute of the seventh character. The fifth character, the sixth character and the seventh character are input into a pre-trained font generation network to obtain a target character. The font content of the target character is the font content provided by the fifth character, and the font attribute of the target character is determined by the font attribute of the sixth character and the font attribute of the seventh character. In the present application, since the training samples used by the font generation network during training include a first character and a second character with different font attributes, the trained font generation network can accurately extract the font attributes of different characters, and obtain new font attributes by interpolating different font attributes.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a font generation method, device and equipment. Background Art

[0002] In the fields of personalized advertising and personalized content recommendation, fonts with unique styles are often a means of highlighting the personality of users. The diversity and richness of fonts have also attracted the attention of users and advertisers. A font is often determined by the various attributes of the word when it is visualized, including but not limited to the skeleton of the word, the thickness of the word, the stroke of the word, etc. By arranging and combining the attributes, a variety of fonts can be combined.

[0003] The generation of new fonts often requires designers, but the cost and cycle of designing new fonts is high. Summary of the invention

[0004] In view of this, embodiments of the present application provide a font generation method, device and apparatus to achieve the generation of new fonts and improve font generation efficiency.

[0005] To achieve the above purpose, the technical solutions provided by the embodiments of the present application are as follows:

[0006] In a first aspect of an embodiment of the present application, a font generation method is provided, the method comprising:

[0007] Acquire a fifth character providing font content and a character set providing font attributes, the character set including a sixth character and a seventh character, the font attribute of the sixth character is different from the font attribute of the seventh character, and the font attribute is used to reflect the style of the font;

[0008] Inputting the fifth character, the sixth character and the seventh character into a font generation network to obtain a target character, wherein the font content of the target character is the font content provided by the fifth character, and the font attribute of the target character is determined by the font attribute of the sixth character and the font attribute of the seventh character;

[0009] The font generation network is generated by training using training samples, the training samples include a first character and a second character, and the font attribute of the first character is different from the font attribute of the second character.

[0010] In a second aspect of the embodiment of the present application, a font generation device is provided, the device comprising:

[0011] an acquiring unit, configured to acquire a fifth character providing font content and a character set providing font attributes, the character set including a sixth character and a seventh character, the font attribute of the sixth character being different from the font attribute of the seventh character, and the font attribute being used to reflect the style of the font;

[0012] a generating unit, configured to input the fifth character, the sixth character and the seventh character into a font generating network to obtain a target character, wherein the font content of the target character is the font content provided by the fifth character, and the font attribute of the target character is determined by the font attribute of the sixth character and the font attribute of the seventh character;

[0013] The font generation network is generated by training using training samples, the training samples include a first character and a second character, and the font attribute of the first character is different from the font attribute of the second character.

[0014] In a third aspect of the embodiments of the present application, an electronic device is provided, the device comprising: a processor and a memory;

[0015] The memory is used to store instructions or computer programs;

[0016] The processor is used to execute the instructions or computer programs in the memory, so that the electronic device executes the font generation method described in the first aspect.

[0017] In a fourth aspect of the implementation of the present application, a computer-readable storage medium is provided, wherein instructions are stored in the computer-readable storage medium. When the instructions are executed on a device, the device executes the font generation method described in the first aspect.

[0018] In a fifth aspect of the embodiments of the present application, a computer program product is provided. When the computer program product is run on a computer, the computer executes the font generation method described in the first aspect.

[0019] It can be seen that the embodiments of the present application have the following beneficial effects:

[0020] When generating a new font, the embodiment of the present application obtains a fifth character that provides font content and a character set that provides font attributes, and the character set includes a sixth character and a seventh character. Among them, the font attribute of the sixth character is different from the font attribute of the seventh character, and different font attributes reflect different font styles. The fifth character, the sixth character and the seventh character are input into a pre-trained font generation network to obtain a target character. Among them, the font content of the target character is the font content provided by the fifth character, and the font attribute of the target character is determined by the font attribute of the sixth character and the font attribute of the seventh character. That is, the font generation network can extract the respective font attributes from the sixth character and the seventh character, and generate a new font attribute using the two font attributes, and then generate the target character using the new font attribute. In the present application, since the training samples used by the font generation network during training include the first character and the second character with different font attributes, the trained font generation network can accurately extract the font attributes of different characters, and obtain new font attributes by interpolating different font attributes. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0022] Figure 1 A flow chart of a font generation network training method provided in an embodiment of the present application;

[0023] Figure 2 A font generation network framework diagram provided in an embodiment of the present application;

[0024] Figure 3 A flow chart of a font generation method provided in an embodiment of the present application;

[0025] Figure 4 Another font generation network framework diagram provided in an embodiment of the present application;

[0026] Figure 5 A schematic diagram of the structure of a font generation device provided in an embodiment of the present application;

[0027] Figure 6 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0028] To enable those skilled in the art to better understand the solution of this application, the following will clearly and completely describe the technical solution in the embodiments of this application in conjunction with the accompanying drawings in the embodiments of this application. Obviously, the described embodiments are only a part of the embodiments of this application, rather than all the embodiments. Based on the embodiments in this application, all other embodiments obtained by those of ordinary skill in the art without creative efforts belong to the scope of protection of this application.

[0029] To facilitate the understanding of the technical solution provided in the embodiments of this application, the following will first explain the technical terms involved in this application.

[0030] A font refers to the external form characteristics of characters, that is, the style of characters. Usually, the birth of a font goes through processes such as the creative design of font designers, the one-by-one production and modification by font production personnel. For example, it includes seal script, official script, regular script, cursive script, Song typeface, boldface, etc.

[0031] The currently common application is to perform font style conversion, that is, to convert one font style into another. For example, generative adversarial networks (GANs) are used to achieve style conversion. However, font style conversion can only be achieved between existing fonts and cannot generate new fonts. The generation of new fonts must rely on designers spending time and effort to obtain, increasing the design cost.

[0032] Based on this, the embodiments of this application provide a font generation method. Through training, the font generation network can decouple and encode the font content and font attributes of characters, then interpolate the attribute encodings of different fonts to obtain new attribute encodings, and further generate new fonts based on the new attribute encodings and content encodings.

[0033] It should be noted that usually, a font is determined by multiple font attributes, which may include the skeleton, thickness, and pen tip of the character. Font content refers to the content carrying the font, that is, the specific character. For example, for the regular script "中", the font content is "中".

[0034] Based on the above description, the following will explain a font generation network training method provided in the embodiments of this application in conjunction with the accompanying drawings.

[0035] See Figure 1 , which is a flowchart of a font generation network training method provided in the embodiments of this application. The initial network model corresponding to this font generation network includes an attribute encoder, a content encoder, and a decoder. As Figure 1 shown, this method may include:

[0036] S101: Obtain training samples, which include a first character and a second character.

[0037] In this embodiment, to make the trained font generation network more accurate, a large number of training samples can be obtained. The training samples can include a first character and a second character. Among them, the first character can provide font attributes during training, and the second character can provide font content during training. Among them, the font attributes of the first character are different from those of the second character, and the font content of the first character is also different from that of the second character. For example, the first character is "你" in Song font, and the second character is "好" in Kai font. During training, the first character provides the font attribute of Song font, and the second character provides the content of the character "好".

[0038] S102: Input the first character into the attribute encoder to obtain a first attribute code, and input the second character into the content encoder to obtain a first content code.

[0039] After obtaining the training samples, the first character is used as an input parameter and input into the attribute encoder to obtain the first attribute code corresponding to the font of the first character. The second character is used as an input parameter and input into the content encoder to obtain the font content of the second character, that is, the second content code. Among them, the first attribute code is the font attribute feature vector of the first character, which can represent the font of the first character. For example, the first attribute code is used to represent that the font of the first character is Song font. The first content code is the font content feature vector of the second character, which can represent the specific content of the second character. For example, the first content code is used to represent that the second character is the character "好".

[0040] Optionally, to improve the encoding accuracy of the content encoder and avoid the loss of strokes during the encoding process, when encoding the second character, the stroke information corresponding to the second character can also be used as an input parameter and input into the content encoder together, so that the first content code output by the content encoder can accurately reflect the second character. Specifically, the second character and the stroke code corresponding to the second character are input into the content encoder to obtain the first content code. Among them, the stroke code is used to represent the radicals included in the second character.

[0041] Among them, a stroke is the smallest unit that makes up a Chinese character, and each character can be composed of several radicals. The stroke code is the code vector corresponding to a certain character. If it includes a certain radical, the corresponding code value can be set to 1, otherwise it is set to 0. For example, there are a total of 32 radicals, so the stroke code is a 32-dimensional code vector.

[0042] S103: Input the first attribute code and the first content code into the decoder to obtain a third character.

[0043] After obtaining the first attribute code and the first content code, use them as input parameters and input them into the decoder. Through the decoding operation, obtain the third character. Among them, the font of the third character output by the decoder is the font of the first character, and the font content is the content of the second character. For example, if the first character is the Song typeface "你" and the second character is the regular script "好", then the third character is the Song typeface "好".

[0044] Optionally, in order to make the font attributes of the generated third character closer to the font attributes of the first character, the first character (attribute character) and the second character (content character) can also be regionally segmented, and for each region of the content character, find a similar attribute character partition. Then, when decoding, it can be decoded by region. Specifically, segment the first character and the second character to obtain multiple first partitions corresponding to the first character and multiple second partitions corresponding to the second character; for any second partition, determine the first partition that matches the second partition from the multiple first partitions corresponding to the first character; for any second partition, input the content code of the second partition and the attribute code of the first partition that matches the second partition into the decoder to obtain the third character. Among them, the connected component segmentation algorithm can be used to segment the first character and the second character. For example, divide the first character into region 11, region 12, and region 13, and divide the second character into region 21, region 22, region 23, and region 24. For the 4 regions divided by the second character, find similar regions for each region of the second character from the 3 regions divided by the first character. Then, the decoder decodes based on a pair of matching regions, thereby improving the decoding accuracy.

[0045] S104: Input the second character into the attribute encoder to obtain the second attribute code, and input the third character into the content encoder to obtain the second content code.

[0046] In this embodiment, input the second character as an input parameter into the attribute encoder to obtain the second attribute code corresponding to the font of the second character, and input the third character as an input parameter into the content encoder to obtain the font content of the third character, that is, the second content code. For example, if the second character is the regular script "好", and the third character is the Song typeface "好", then the second attribute code is used to represent that the character of the second character is the regular script, and the second content code is used to represent that the font content of the third character is "好".

[0047] Optionally, when encoding the content of the third character, input the third character and the stroke code corresponding to the third character into the content encoder to obtain the second content code.

[0048] S105: Input the second attribute code and the second content code into the decoder to obtain the fourth character.

[0049] The second attribute encoding corresponding to the second character and the second content encoding corresponding to the third character are input as input parameters into the decoder, and the fourth character is obtained through a decoding operation. That is, the original content character is reconstructed by using the generated character (the third character) as the content character and the original content character (the second character) as the attribute character. For example, if the first character is the Song typeface "你" (nǐ), and the second character is the regular script "好" (hǎo), then the generated character is the third character, which is the Song typeface "好" (hǎo), and the reconstructed fourth character is the regular script "好" (hǎo).

[0050] S106: Adjust the parameters of the initial network model based on the font content of the second character and the font content of the fourth character.

[0051] After obtaining the fourth character, the parameters of the initial network model are adjusted based on the difference between the font content of the second character and the font content of the fourth character. Specifically, the parameters of the content encoder in the initial network model are adjusted based on the font content of the second character and the font content of the fourth character to improve the encoding accuracy of the content encoder.

[0052] Optionally, the second character and the fourth character are input into the first discriminator, and the parameters of the initial network model are adjusted according to the discrimination result of the first discriminator. Among them, the first discriminator is used to discriminate the difference between the font content of the second character and the font content of the fourth character, and a discrimination loss function can be obtained through this first discriminator to adjust the parameters of the initial network model by using this discrimination loss function.

[0053] Optionally, to further improve the encoding accuracy of the content encoder, the parameters of the initial network model can also be adjusted based on the difference between the stroke encoding corresponding to the third character and the stroke encoding corresponding to the second character. Specifically, the third character is input into the stroke classifier to obtain the first stroke encoding; the parameters of the initial network model are adjusted according to the first stroke encoding and the second stroke encoding corresponding to the second character. For example, the first stroke encoding and the second stroke encoding are input into the third discriminator, and the parameters of the content encoder are adjusted according to the discrimination result of the third discriminator. The third discriminator is used to discriminate the difference between the first stroke encoding and the second stroke encoding.

[0054] S107: Adjust the parameters of the initial network model based on the font attribute of the first character and the font attribute of the third character, and re-execute the above training process until the preset condition is met to obtain the font generation network.

[0055] In this embodiment, the parameters of the initial network model are adjusted by using the difference between the font attribute of the first character and the font attribute of the third character. Specifically, the parameters of the attribute encoder in the initial network model are adjusted based on the font attribute of the first character and the font attribute of the third character to improve the encoding accuracy of the attribute encoder.

[0056] Optionally, the first character and the third character are input into a second discriminator, and the parameters of the initial network model are adjusted according to the identification result of the second discriminator. The second discriminator is used to identify the difference between the font attribute of the second character and the font attribute of the fourth character, and the identification loss function is obtained by the second discriminator, so as to adjust the parameters of the attribute encoder using the identification loss function.

[0057] After adjusting the parameters of the initial network model based on S106 and S107, the training process of S102-S107 is re-executed until the preset conditions are met to obtain a font generation network. The preset conditions can be set according to actual conditions, for example, the identification loss function of the first discriminator is less than a first preset threshold and / or the identification loss function of the second discriminator is less than a second preset threshold.

[0058] It should be noted that the execution order of S106 and S107 in this embodiment is not limited to the above, and S107 may be executed first, then S106, or S106 and S107 may be executed simultaneously. Also, the execution order of S107 and S104-S106 is not limited to the above, and S107 may be executed first, then S104-S106, or S107 and S104-S106 may be executed simultaneously.

[0059] It can be seen that when training the font generation network, a training sample is obtained, which includes a first character and a second character, wherein the first character is used to provide font attributes and the second character is used to provide font content. The first character is input into the attribute encoder of the initial network model to obtain a first attribute code, and the second character is input into the content encoder of the initial network model to obtain a first content code. The first attribute code and the first content code are input into the decoder of the initial network model to obtain a third character, and the third character is input into the content encoder to obtain a second content code, and the second character is input into the attribute encoder to obtain a second attribute code. The second attribute code and the second content code are input into the decoder to obtain a fourth character. The parameters of the initial network model are adjusted based on the font content of the second character and the font content of the fourth character, and the parameters of the initial network model are adjusted based on the font attributes of the first character and the font attributes of the third character. After the adjustment, the above training process is re-executed until the preset jump is met to obtain a font generation network. The parameters of the initial network model are adjusted based on the font content of the second character and the font content of the fourth character, mainly adjusting the content encoder so that the content encoder can accurately encode the content of the input character, and the parameters of the initial network model are adjusted based on the font attribute of the first character and the font attribute of the third character, mainly adjusting the attribute encoder so that the attribute encoder can accurately encode the attribute of the input character. Through the above training, the attribute encoder and the content encoder are decoupled.

[0060] See also Figure 2 The initial network model architecture diagram shown in the figure includes an attribute encoder, a content encoder, a decoder, a first discriminator and a second discriminator. The first character is input into the attribute encoder to obtain a first attribute code, and the second character and the stroke code are input into the content encoder to obtain a first content code. The decoder decodes the first attribute code and the first content code to obtain a third character.

[0061] The second character is then input into the attribute encoder to obtain a second attribute code, the third character and the stroke code are input into the content encoder to obtain a second content code, and the decoder performs a decoding operation based on the second attribute code and the second content code to obtain a fourth character.

[0062] The first character and the third character are input into the second discriminator, and the obtained loss is fed back to the attribute encoder. The second character and the fourth character are input into the first discriminator, and the obtained loss is fed back to the content encoder.

[0063] Based on the font generation network generated by the above training, the font generation network will be used to generate new fonts.

[0064] See also Figure 3, which is a flow chart of a font generation method provided in an embodiment of the present application, such as Figure 3 As shown, the method may include:

[0065] S301: Acquire a fifth character providing font content and a character set providing font attributes, wherein the character set includes a sixth character and a seventh character.

[0066] In this embodiment, in order to obtain a new font, the fifth character and the character set are obtained, wherein the fifth character is used to provide font content, and the characters in the character set are used to provide font attributes, and the character set may include multiple characters with different font attributes, and the font attributes may reflect the specific style of the font.

[0067] S302: Inputting the fifth character, the sixth character and the seventh character into the font generation network to obtain the target character.

[0068] After obtaining the fifth character providing font content and the sixth character and the seventh character providing font attributes, the above characters are input into the font generation network to obtain a target character through the font generation network. The font content of the target character is the font content provided by the fifth character, the font attributes of the target character are determined by the font attributes of the sixth character and the font attributes of the seventh character, and the font attributes of the target character are different from the font attributes of the sixth character and the font attributes of the seventh character.

[0069] From the above, it can be known that the font generation network may include an attribute encoder and a content encoder. After obtaining the fifth character, the sixth character, and the seventh character, the font generation network will use the attribute encoder and the content encoder to process the above characters respectively, which may specifically include the following steps:

[0070] 1): Input the sixth character and the seventh character into the attribute encoder of the font generation network to obtain the sixth attribute code and the seventh attribute code respectively.

[0071] 2): Mix the sixth attribute code and the seventh attribute code to obtain the target attribute code.

[0072] In this embodiment, the sixth character and the seventh character used to provide font attributes are input into the attribute encoder of the font generation network to obtain the sixth attribute code corresponding to the first character and the seventh attribute code corresponding to the seventh character. Then, the sixth attribute code and the seventh attribute code are mixed to obtain the target attribute code, which is used to characterize the new font attribute. Specifically, the sixth attribute code and the seventh attribute code are input into the mixer of the font generation network to obtain the target attribute code. The mixer can mix the sixth attribute code and the seventh attribute code in a weighted manner to obtain the target attribute code.

[0073] 3): Input the fifth character into the content encoder of the font generation network to obtain the target content encoding.

[0074] Optionally, when the content code corresponding to the fifth character is obtained, the fifth character and the stroke code corresponding to the fifth character may be input into the content encoder, so that the target content code output by the content encoder is more accurate.

[0075] 4): Input the target attribute encoding and the target content encoding into the decoder of the font generation network to obtain the target character.

[0076] When the decoder performs decoding operations on the target attribute code and the target content code to generate the target character, the SPADE method can be used for decoding to enhance the strength of the target attribute code, so that the font attribute of the generated target character is more prominent.

[0077] It can be seen that after the attribute encoder and content encoder in the font generation network are decoupled, the attribute encoder can be used to extract the attribute encoding of the sixth character and the attribute encoding of the seventh character, and a new target attribute encoding can be obtained by interpolation. The new target attribute encoding represents the new font. After decoding the target attribute encoding and the target content encoding, the new font can be obtained.

[0078] See also Figure 4 In the scene diagram shown, the font generation network includes an attribute encoder, a content encoder, a decoder and a mixer. The fifth character and the stroke code are input into the content encoder to obtain the target content code, and the sixth character and the seventh character are input into the attribute encoder to obtain the sixth attribute code and the seventh attribute code, and the target attribute code is obtained through the mixer. The decoder obtains the target character by decoding the target content code and the target attribute code.

[0079] Based on the above method embodiment, the embodiment of the present application provides a font generation device and apparatus, which will be described below in conjunction with the accompanying drawings.

[0080] See also Figure 5 , which is a structural diagram of a font generation device provided in an embodiment of the present application, such as Figure 5 As shown, the device may include: an acquisition unit 501 and a generation unit 502.

[0081] An acquiring unit 501 is used to acquire a fifth character providing font content and a character set providing font attributes, the character set including a sixth character and a seventh character, the font attribute of the sixth character is different from the font attribute of the seventh character, and the font attribute is used to reflect the style of the font;

[0082] A generating unit 502 is used to input the fifth character, the sixth character and the seventh character into a font generating network to obtain a target character, wherein the font content of the target character is the font content provided by the fifth character, and the font attribute of the target character is determined by the font attribute of the sixth character and the font attribute of the seventh character;

[0083] The font generation network is generated by training using training samples, the training samples include a first character and a second character, and the font attribute of the first character is different from the font attribute of the second character.

[0084] In a specific implementation, the device further includes: a training unit;

[0085] The training unit is used to input the first character into the attribute encoder to obtain a first attribute code, and input the second character into the content encoder to obtain a first content code; input the first attribute code and the first content code into the decoder to obtain a third character; input the second character into the attribute encoder to obtain a second attribute code, and input the third character into the content encoder to obtain a second content code; input the second attribute code and the second content code into the decoder to obtain a fourth character; adjust the parameters of the initial network model based on the font content of the second character and the font content of the fourth character; adjust the parameters of the initial network model based on the font attribute of the first character and the font attribute of the third character, and re-execute the above training process until the preset conditions are met to obtain a font generation network.

[0086] In a specific implementation, the training unit is specifically used to input the second character and the stroke code corresponding to the second character into the content encoder to obtain the first content code, wherein the stroke code is used to represent the radical included in the second character.

[0087] In a specific implementation, the training unit is specifically used to input the second character and the fourth character into a first discriminator, and adjust the parameters of the initial network model according to the identification result of the first discriminator, and the first discriminator is used to identify the difference between the font content of the second character and the font content of the fourth character.

[0088] In a specific implementation, the training unit is specifically used to input the first character and the third character into a second discriminator, and adjust the parameters of the initial network model according to the identification result of the second discriminator, and the second discriminator is used to identify the difference between the font attributes of the second character and the font attributes of the fourth character.

[0089] In a specific implementation, the training unit is further used to input the third character into a stroke classifier to obtain a first stroke code; and adjust the parameters of the initial network model according to the first stroke code and a second stroke code corresponding to the second character.

[0090] In a specific implementation, the training unit is specifically used to perform character segmentation on the first character and the second character to obtain multiple first partitions corresponding to the first character and multiple second partitions corresponding to the second character; for any second partition, determine the first partition that matches the second partition from the multiple first partitions corresponding to the first character; for any second partition, input the content code of the second partition and the attribute code of the first partition that matches the second partition into the decoder to obtain a third character.

[0091] In a specific implementation, the generation unit is specifically used to input the sixth character and the seventh character into the attribute encoder of the font generation network to obtain the sixth attribute code and the seventh attribute code respectively; mix the sixth attribute code and the seventh attribute code to obtain a target attribute code, and the target attribute code is used to represent the new font attribute; input the fifth character into the content encoder of the font generation network to obtain a target content code; input the target attribute code and the target content code into the decoder of the font generation network to obtain the target character.

[0092] In a specific implementation, the generating unit is specifically configured to input the fifth character and the stroke code of the fifth character into the content encoder of the font generation network to obtain the target content code.

[0093] In a specific implementation, the generating unit is specifically configured to input the sixth attribute code and the seventh attribute code into a mixer of the font generation network to obtain a target attribute code.

[0094] It should be noted that the implementation of each unit in this embodiment can refer to the above method embodiment, and this embodiment will not be repeated here.

[0095] See also Figure 6, which shows a schematic diagram of the structure of an electronic device 600 suitable for implementing the embodiment of the present application. The terminal device in the embodiment of the present application may include but is not limited to mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (portable android devices), PMPs (Portable Media Players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs (televisions), desktop computers, etc. Figure 6 The electronic device shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.

[0096] like Figure 6 As shown, the electronic device 600 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 601, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 602 or a program loaded from a storage device 608 into a random access memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the electronic device 600 are also stored. The processing device 601, the ROM 602, and the RAM 603 are connected to each other via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.

[0097] Typically, the following devices may be connected to the I / O interface 605: an input device 606 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 607 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 608 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 609. The communication device 609 may allow the electronic device 600 to communicate with other devices wirelessly or by wire to exchange data. Although Figure 6 The electronic device 600 is shown with various devices, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead.

[0098] In particular, according to an embodiment of the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present application includes a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication device 609, or installed from the storage device 608, or installed from the ROM 602. When the computer program is executed by the processing device 601, the above-mentioned functions defined in the method of the embodiment of the present application are executed.

[0099] The electronic device provided in the embodiment of the present application and the font generation method provided in the above embodiment belong to the same inventive concept. The technical details not fully described in this embodiment can be referred to the above embodiment, and this embodiment has the same beneficial effects as the above embodiment.

[0100] An embodiment of the present application provides a computer-readable medium having a computer program stored thereon, wherein when the program is executed by a processor, the font generation method as described in any of the above embodiments is implemented.

[0101] It should be noted that the computer-readable medium mentioned above in the present application may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present application, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present application, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. The computer readable signal medium may also be any computer readable medium other than a computer readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer readable medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.

[0102] In some embodiments, the client and the server may communicate using any currently known or future developed network protocol such as HTTP (Hyper Text Transfer Protocol), and may be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), an internet (e.g., the Internet), and a peer-to-peer network (e.g., an ad hoc peer-to-peer network), as well as any currently known or future developed network.

[0103] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.

[0104] The computer-readable medium carries one or more programs. When the one or more programs are executed by the electronic device, the electronic device executes the font generation method.

[0105] Computer program code for performing the operations of the present application may be written in one or more programming languages ​​or a combination thereof, including, but not limited to, object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0106] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present application. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0107] The units involved in the embodiments described in this application may be implemented by software or hardware. The name of a unit / module does not limit the unit itself in some cases. For example, a voice data acquisition module may also be described as a "data acquisition module".

[0108] The functions described above herein may be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), and the like.

[0109] In the context of the present application, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0110] It should be noted that the various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments, and the same or similar parts between the various embodiments can be referred to each other. For the system or device 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 description.

[0111] It should be understood that in the present application, "at least one (item)" means one or more, and "plurality" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the objects associated before and after are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.

[0112] It should also be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.

[0113] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.

[0114] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A font generation method, characterized in that: The method comprises: Acquire a fifth character providing font content and a character set providing font attributes, the character set including a sixth character and a seventh character, the font attribute of the sixth character is different from the font attribute of the seventh character, and the font attribute is used to reflect the style of the font; Inputting the fifth character, the sixth character and the seventh character into a font generation network to obtain a target character, wherein the font content of the target character is the font content provided by the fifth character, and the font attribute of the target character is determined by the font attribute of the sixth character and the font attribute of the seventh character; The font generation network is generated by training using training samples, the training samples include a first character and a second character, the font attribute of the first character is different from the font attribute of the second character, the initial network model corresponding to the font generation network includes an attribute encoder, a content encoder and a decoder, and the training process of the font generation network includes: Input the first character into the attribute encoder to obtain a first attribute code, and input the second character into the content encoder to obtain a first content code; input the first attribute code and the first content code into the decoder to obtain a third character; input the second character into the attribute encoder to obtain a second attribute code, and input the third character into the content encoder to obtain a second content code; input the second attribute code and the second content code into the decoder to obtain a fourth character; adjust the parameters of the initial network model based on the font content of the second character and the font content of the fourth character; adjust the parameters of the initial network model based on the font attribute of the first character and the font attribute of the third character, and re-execute the above training process until the preset conditions are met to obtain a font generation network.

2. The method according to claim 1, characterized in that Inputting the third character into the content encoder to obtain a second content code comprises: The second character and the stroke code corresponding to the second character are input into the content encoder to obtain the first content code, wherein the stroke code is used to represent the radical included in the second character.

3. The method according to claim 1 or 2, characterized in that: The adjusting the parameters of the initial network model based on the font content of the second character and the font of the fourth character includes: The second character and the fourth character are input into a first discriminator, and the parameters of the initial network model are adjusted according to the identification result of the first discriminator, wherein the first discriminator is used to identify the difference between the font content of the second character and the font content of the fourth character.

4. The method according to claim 1, characterized in that: The adjusting the model parameters of the initial network based on the font attribute of the first character and the font attribute of the third character includes: The first character and the third character are input into a second discriminator, and the parameters of the initial network model are adjusted according to the identification result of the second discriminator, wherein the second discriminator is used to identify the difference between the font attribute of the second character and the font attribute of the fourth character.

5. The method according to claim 1, characterized in that The method further comprises: Inputting the third character into a stroke classifier to obtain a first stroke code; The parameters of the initial network model are adjusted according to the first stroke code and the second stroke code corresponding to the second character.

6. The method according to claim 1, characterized in that Inputting the first attribute code and the first content code into the decoder to obtain a third character includes: Performing character segmentation on the first character and the second character to obtain a plurality of first partitions corresponding to the first character and a plurality of second partitions corresponding to the second character; For any second partition, determining a first partition matching the second partition from a plurality of first partitions corresponding to the first character; For any second partition, the content code of the second partition and the attribute code of the first partition matching the second partition are input into the decoder to obtain a third character.

7. The method according to claim 1, characterized in that The step of inputting the fifth character, the sixth character and the seventh character into a font generation network to obtain a target character comprises: Inputting the sixth character and the seventh character into the attribute encoder of the font generation network to obtain a sixth attribute code and a seventh attribute code respectively; Mixing the sixth attribute code and the seventh attribute code to obtain a target attribute code, wherein the target attribute code is used to represent a new font attribute; Inputting the fifth character into the content encoder of the font generation network to obtain a target content encoding; The target attribute code and the target content code are input into a decoder of the font generation network to obtain a target character.

8. The method according to claim 7, characterized in that Inputting the fifth character into the content encoder of the font generation network to obtain a target content encoding comprises: The fifth character and the stroke code of the fifth character are input into the content encoder of the font generation network to obtain the target content code.

9. The method according to claim 7 or 8, characterized in that: The step of mixing the sixth attribute code and the seventh attribute code to obtain a target attribute code includes: The sixth attribute code and the seventh attribute code are input into a mixer of the font generation network to obtain a target attribute code.

10. A font generation device, characterized in that: The device comprises: an acquiring unit, configured to acquire a fifth character providing font content and a character set providing font attributes, the character set including a sixth character and a seventh character, the font attribute of the sixth character being different from the font attribute of the seventh character, and the font attribute being used to reflect the style of the font; a generating unit, configured to input the fifth character, the sixth character and the seventh character into a font generating network to obtain a target character, wherein the font content of the target character is the font content provided by the fifth character, and the font attribute of the target character is determined by the font attribute of the sixth character and the font attribute of the seventh character; The font generation network is generated by training using training samples, the training samples include a first character and a second character, the font attribute of the first character is different from the font attribute of the second character, the initial network model corresponding to the font generation network includes an attribute encoder, a content encoder and a decoder, and the training process of the font generation network includes: inputting the first character into the attribute encoder to obtain a first attribute code, and inputting the second character into the content encoder to obtain a first content code; inputting the first attribute code and the first content code into the decoder to obtain a third character; inputting the second character into the attribute encoder to obtain a second attribute code, and inputting the third character into the content encoder to obtain a second content code; inputting the second attribute code and the second content code into the decoder to obtain a fourth character; adjusting the parameters of the initial network model based on the font content of the second character and the font content of the fourth character; adjusting the parameters of the initial network model based on the font attribute of the first character and the font attribute of the third character, and re-executing the above training process until the preset conditions are met to obtain the font generation network.

11. An electronic device, characterized in that: The device comprises: a processor and a memory; The memory is used to store instructions or computer programs; The processor is used to execute the instructions or computer programs in the memory, so that the electronic device executes the font generation method according to any one of claims 1 to 9.

12. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores instructions, and when the instructions are executed on a device, the device executes the font generation method according to any one of claims 1 to 9.

Citation Information

Patent Citations

  • Art character editing method and system combining stylization and destylization

    CN110097615A

  • Character recognition model training method and device and electronic equipment

    CN112364860A