Font generation method and device

By finding and using similar text styles, the radical styles of new text are migrated to the font generation network, solving the problem of inconsistent font styles in the existing technology, and achieving the overall style unity and aesthetic improvement after image editing.

CN119106655APending Publication Date: 2024-12-10ZHUHAI KINGSOFT OFFICE SOFTWARE +2
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202310674110.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-06-07
Publication Date
2024-12-10

AI Technical Summary

Technical Problem

When editing text in images, the prior art cannot guarantee that the added text font style is consistent with the original image, resulting in inconsistent font styles of the edited image and poor aesthetics.

Method used

By obtaining the semantic information of the newly added text and the original text information in the target image, search for the close-shaped text and input it into the font generation network to generate text after the font style is transferred, ensuring that the radical style and close-shaped text of the newly added text are the close-range text. The text is consistent in style.

Benefits of technology

The edited image font style is similar to the overall style of the target image, improving the overall effect of font generation, making it simple and efficient.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119106655A_ABST
    Figure CN119106655A_ABST
Patent Text Reader

Abstract

The invention provides a font generation method and device, and relates to the technical field of artificial intelligence, and the font generation method comprises the steps: obtaining the semantic information of a newly-added character and the semantic information of each original character in a target image; searching for radicals and structures of the newly added characters and radicals and structures of the original characters according to the semantic information; according to the structure and the radicals, the newly added characters are matched with the original characters, and at least one character similar in shape is screened out from the original characters; and inputting the character image of the newly-added character and the character image of each character with the similar shape in the target image into a font generation network, and generating the newly-added character after font style migration. The character components of the newly-added characters can appear in the character pictures of characters similar in shape, font style migration of the newly-added characters is facilitated, the generated fonts are close to the target picture in style, the method is simple, convenient and efficient, and the overall effect of font generation is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical field

[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a font generation method and device. Background technology

[0002] With the continuous development of Internet technology, a variety of information flow products emerge in endlessly, among which images are the most common, such as images and texts of public accounts, product advertising images, etc. Images often contain a large amount of text information to help readers better understand the content of the image. Due to the need to modify the image content, the text information in the image needs to be edited.

[0003] In the existing technology, text recognition technology is generally used to extract text from images, and the extracted text is converted into editable text for users to edit. However, this method can only edit text content, such as adding text, deleting text, etc. For the added text, there is no guarantee that the font style will be the same as the original. Figure 1 Consistent, resulting in inconsistent font style and poor aesthetics of the edited image. Therefore, an effective solution is urgently needed to solve the above problems. Contents of the invention

[0004] In order to solve the problems existing in the prior art, embodiments of the present invention provide a font generation method and device.

[0005] The invention provides a font generation method, which includes:

[0006] Obtain the semantic information of the newly added text and the semantic information of each original text in the target image;

[0007] Search the radicals and structures of the newly added characters according to the semantic information, as well as the radicals and structures of each original character;

[0008] According to the structure and the radicals, match the newly added characters with each of the original characters respectively, and select at least one similar character from each of the original characters;

[0009] The text image of the newly added text and the text images of each similar text in the target image are input into a font generation network to generate the new text after font style migration.

[0010] According to a font generation method provided by the present invention, before inputting the text image of the newly added text and the text images of each similar text in the target image to the font generation network, it also includes:

[0011] Find the stroke number of each original text according to the semantic information;

[0012] Determine the original text whose number of strokes meets the preset stroke conditions as the stroke reference text;

[0013] Correspondingly, inputting the text image of the newly added text and the text images similar to each text in the target image to the font generation network includes:

[0014] The text image of the newly added text, the text image of each similar text in the target image, and the text image of each stroke reference text are input to the font generation network.

[0015] According to a font generation method provided by the present invention, the newly added characters are matched with each of the original characters according to the structure and the radicals, and at least one font is selected from each of the original characters. Near text, including:

[0016] Screen at least one alternative text from each of the original texts, and the structure of the alternative text is the same as the structure of the new text;

[0017] For each candidate text, compare the radicals of the candidate text and the radicals of the new text, and determine the number of identical radicals of the candidate text and the new text;

[0018] The candidate character with the largest number of same radicals is determined as the first closely related character.

[0019] According to a font generation method provided by the present invention, after determining the candidate character with the largest number of same radicals as the first closely related character, the method further includes:

[0020] The candidate text containing the specified radical is determined as a second closely related character, and the specified radical is a radical included in the radical of the newly added character and not included in the radical of the first closely related character.

[0021] According to a font generation method provided by the present invention, obtaining the semantic information of the newly added text and the semantic information of each original text in the target image includes:

[0022] Obtaining each text paragraph in the target image, each display text contained in each text paragraph, and the semantic information of each display text;

[0023] If a text adding operation for the target image is detected, the position information corresponding to the text adding operation, the new text and the semantic information of the new text are obtained;

[0024] Determine the target text paragraph corresponding to the position information;

[0025] Each displayed text included in the target text paragraph is determined as an original text.

[0026] According to a font generation method provided by the present invention, obtaining the semantic information of the newly added text and the semantic information of each original text in the target image includes:

[0027] Obtain each text paragraph in the target image and each display text contained in each text paragraph;

[0028] If a text adding operation for the target image is detected, the location information and new text corresponding to the text adding operation are obtained;

[0029] Determine the target text paragraph corresponding to the position information;

[0030] Determine each displayed text contained in the target text paragraph as original text respectively;

[0031] Obtain the semantic information of each original text and the semantic information of the newly added text.

[0032] According to a font generation method provided by the present invention, before inputting the text image of the newly added text and the text images of each similar text in the target image to the font generation network, it also includes:

[0033] For each character that is similar to the character, if there are multiple initial character images that are similar to the character in the target image, the initial character image with the largest image size is determined as the target character image that is similar to the character.

[0034] According to a font generation method provided by the present invention, searching for the radicals and structures of the newly added characters according to the semantic information, as well as the radicals and structures of each original character, includes:

[0035] According to the semantic information of the newly added text, search the radicals and structures of the newly added text from a text information database, where the semantic information, radicals and structures of each text are stored in the text information database;

[0036] According to the semantic information of each original text, the radicals and structures of each original text are respectively searched from the text information database.

[0037] According to a font generation method provided by the present invention, the text image of the newly added text and the text images of each similar text in the target image are input to a font generation network, and the new font style migrated font is generated. Before adding text, also include:

[0038] Obtain a training set and an initial font generation network, wherein the training set includes a plurality of text image groups, and the text image group includes a training text image, a label text image, and at least one font style image;

[0039] Extract a first text image group from the training set, input the at least one font style image and the training text image in the first text image group into the initial font generation network to obtain a predicted text image, The first text image group is any text image group;

[0040] Calculate a loss value based on the predicted text image and the label text image in the first text image group;

[0041] According to the loss value, the parameters of the initial font generation network are adjusted, and the step of extracting the first text image group from the training set is continued until the preset stop condition is reached, and a trained target font generation network is obtained.

[0042] The invention also provides a font generating device, including:

[0043] The acquisition module is configured to acquire the semantic information of the newly added text and the semantic information of each original text in the target image;

[0044] A search module configured to search for the radicals and structures of the newly added characters and the radicals and structures of each original character according to the semantic information;

[0045] A screening module configured to match the newly added characters with each of the original characters according to the structure and the radicals, and filter out at least one closely related character from each of the original characters;

[0046] The generation module is configured to input the text image of the newly added text and the text images of each similar text in the target image to the font generation network, and generate the new text after font style migration.

[0047] The present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, it implements any of the above font generation methods. .

[0048] The present invention also provides a non-transitory computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, it implements any of the above font generating methods.

[0049] The present invention also provides a computer program product, which includes a computer program. When the computer program is executed by a processor, it implements any one of the above font generating methods.

[0050] The font generation method and device provided by the present invention determine the morphologically similar characters corresponding to the newly added characters through the structure and radicals, so that the radicals of the newly added characters can appear in the text pictures of the similar characters, which is conducive to the font generation network to convert the radicals into The style is transferred to the newly added text, making the final generation effect close to the overall style of the target image, simple and efficient, and improving the overall effect of font generation. Description of the drawings

[0051] In order to explain the present invention or the technical solutions in the prior art more clearly, the drawings needed to be used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings in the following description are of the present invention. For some embodiments of the invention, those of ordinary skill in the art can also obtain other drawings based on these drawings without exerting creative efforts.

[0052] Figure 1 It is a schematic flow chart of the font generation method provided by the present invention;

[0053] Figure 2 It is a schematic structural diagram of the font generation network provided by the present invention;

[0054] Figure 3 It is a schematic diagram of the processing flow of the font generation network provided by the present invention;

[0055] Figure 4 It is a schematic diagram of the effect of the font generation method provided by the present invention;

[0056] Figure 5 It is a schematic structural diagram of the font generating device provided by the present invention;

[0057] Figure 6This is a schematic structural diagram of the electronic device provided by the present invention. Detailed implementation

[0058] In order to make the purpose, technical solutions and advantages of the present invention clearer, the technical solutions in the present invention will be clearly and completely described below in conjunction with the accompanying drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention. , not all examples. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without making creative efforts fall within the scope of protection of the present invention.

[0059] In order to facilitate a clearer understanding of the embodiments of the present invention, some relevant background knowledge is first introduced as follows.

[0060] With the continuous development of Internet technology, a variety of information flow products emerge in endlessly, among which images are the most common, such as official account pictures and text, product advertising pictures, etc. Images often contain a large amount of text information to help readers better understand the content of the image.

[0061] Due to the need to modify the image content, the text information in the image needs to be edited. Generally, the text in the image is extracted through text recognition technology, and then the extracted text is converted into editable text for users to edit. However, this only enables editing of text content, such as adding text, deleting text, etc. For the added text, there is no guarantee that the font style will be the same as the original. Figure 1 Consistent, resulting in inconsistent font style and poor aesthetics of the edited image.

[0062] In response to the above problems, image text editing technology was used. In order to ensure that the page style is relatively neat during the editing process, image text editing technology generally uses a font generation method based on deep learning to generate text in the same direction as the font style on the page. The input of the font generation network generally includes several style images and standard font (such as Song Dynasty) images. The font generation network will extract the font style features of the style image and the semantic features of the standard font at the same time, and finally convert the standard font into the font in the style image. Fonts with similar styles. It can be seen that in the process of generating this text, the selection of style images is particularly important.

[0063] In the prior art, the text image adjacent to the insertion position of the user-added text is usually directly used as the style image. However, when the adjacent text is some simple strokes, such as "one", "two", or Arabic numerals, Because the stroke structure of adjacent text is too simple, the font generation network cannot extract more detailed style features from it, resulting in unsatisfactory generation results.

[0064] Based on the above problems, the present invention provides a font generation method: obtaining the semantic information of the newly added text and the semantic information of each original text in the target image; searching for the radicals and structure of the new text according to the semantic information, and the Describe the radicals and structures of each original text; according to the structure and the radicals , match the newly added text with each of the original texts, and select at least one similar-shaped text from each of the original texts; combine the text image of the newly-added text with each of the similar-shaped characters in the target image. The text image of the text is input to the font generation network to generate the new text after font style migration. Through the structure and radicals, the corresponding morphologically similar characters of the newly added text can be determined, so that the radicals of the new text can appear in the text pictures of the similar characters, which will help the font generation network to transfer the style of the radical to the new text, so that the final The generation effect is close to the overall style of the target image, simple and efficient, and improves the overall effect of font generation.

[0065] Combined below Figure 1-Figure 4 The font generation method of the present invention will be described and explained.

[0066] Figure 1 is a schematic flow chart of the font generation method provided by the present invention, see Figure 1 As shown, it includes steps 101 to 104, where:

[0067] Step 101: Obtain the semantic information of the newly added text and the semantic information of each original text in the target image.

[0068] First of all, it should be noted that the execution subject of the present invention can be any electronic device that generates fonts, such as a smart phone, a smart watch, a desktop computer, a laptop computer, etc.

[0069] Specifically, the target image refers to an image to be edited, that is, an image that requires editing of text content. The format of the target image can be a Joint Photographic Experts Group (JPEG) format, Portable Network Graphics (Portable Network Graphics, PNG) format, Graphics Interchange Format (GIF), Tag Image File Format (Tag Image File Format, TIFF), bitmap image (Bitmap, BMP) format, etc., the present invention does not impose any limitation on this.

[0070] Original text refers to the text that is already included or displayed in the target image before text editing.

[0071] The semantic information represents the entity corresponding to the original text. For example, the semantic information of the original text "I" represents an entity without any personalization or style content such as glyphs and fonts - the text "I".

[0072] New text refers to text added to the text content in the target image. There can be one new text or multiple new words. When there is one newly added text, it can be processed according to the font generation method provided by the present invention; when there are multiple new words, it can be processed according to the font generation method provided by the present invention for each newly added text. .

[0073] In practical applications, before obtaining the semantic information of the new text and the semantic information of each original text in the target image, the target image can be obtained first. There are many ways to obtain the target image. For example, the user uploads the target image through the upload page of the image editing platform, and accordingly, the execution subject obtains the target image; another example is that the execution subject receives an image editing instruction or a font generation instruction, and accordingly , the execution subject obtains the target image from the storage area pointed to by the image editing instruction or the font generation instruction. The present invention is not limited to this.

[0074] On the basis of obtaining the target image, text recognition is further performed on the target image to obtain the semantic information of each original text in the target image. For example, text line detection, optical character recognition (OpticalCharacter Recognition, OCR), single word detection, paragraph detection, etc. are performed on the target image to obtain the semantic information of each original text in the target image.

[0075] Correspondingly, when the user inserts new text into the target image, the semantic information of the new text can be obtained through text recognition technology.

[0076] It should be noted that the semantic information of each original text in the target image can be obtained first, and then the semantic information of the newly added text can be obtained. For example, the user uploads the target image first, and at this time, the semantic information of each original text in the target image can be obtained immediately. Information; when the user edits the target image, the semantic information of the newly added text is obtained. The semantic information of the newly added text and the semantic information of each original text in the target image can be obtained at the same time. For example, the user uploads the target image first, and then obtains the semantic information and target of the new text when the user edits the target image. Semantic information of each original text in the image. It can also be any other way that can be realized now or in the future, and the present invention is not limited to this.

[0077] Step 102: Search the radicals and structures of the newly added characters and the radicals and structures of each original character according to the semantic information.

[0078] Specifically, radicals refer to the indecomposable character-formation symbols in the combined characters of Chinese characters. This indecomposable character-formation symbol is also called "part". For example, "讠" and "正" are both radicals of "正", and "车" ", "Yu" and "攵" are all radicals of "Zhe", and "辶" and "Cun" are both radicals of "Guo".

[0079] Structure, that is, the structure of Chinese characters, that is, the way of combining radicals, includes main upper and lower structures, left and right structures and other structures. Among them, the upper and lower structures include upper and lower structures (such as Si, Wai, Mao, An) and upper, middle and lower structures (such as Cao, violence, Yi, Jing), left-right structures include left-right structures (such as Hao, He, Feng, Xiang, Ming) and left-middle-right structures (such as Xie, tree, pour, move). Other structures include semi-enclosed structures and fully enclosed structures (such as Surround, prison, trapped, field), wear Inserted structures (such as OG, Zhao, Fei, Yi, also called mosaic structures) and pin-shaped structures (such as pin, jing, xin, 焱), and semi-enclosed structures include upper-right enclosing structures (such as ju, ke, si, shi) , upper left surrounding structure (such as temple, hospital , Fang, Ni), the lower left surrounding structure (such as jian, lian, blanket, embarrassment), the upper three surrounding structures (such as, ask, nao, zhou), the lower three surrounding structures (attack, fierce, letter, painting) and the third left Surrounding structure (such as area, giant, circle, box).

[0080] In practical applications, after obtaining the semantic information of each original text in the target image, further, for each original text, the entity of the original text is determined based on the semantic information of the original text, and based on the entity of the original text, the entity of the original text is identified. Radicals and structure of this original text. After obtaining the semantic information of the new text, further, determine the entity of the new text based on the semantic information of the new text, and identify the radicals and structure of the new text based on the entity of the new text.

[0081] For example, if the entity of a certain text is found to be "kind" according to its semantic structure, then the radicals of the text include "wood" and "sheep", and the structure of the text is a "left-right structure".

[0082] It should be noted that a character can have multiple radicals. For example, the radical of "Jing" has two, including "青" and "正", or it can have only one radical. For example, the radical of "一" only includes "一".

[0083] Step 103: Match the new characters with the original characters respectively according to the structure and the radicals, and filter out at least one similar character from each of the original characters.

[0084] Specifically, a close-in character, that is, a close-in character or a close-in reference character, refers to a character that has a similar glyph structure to a newly added character, that is, a character used for reference in the process of generating a new character.

[0085] In a first optional embodiment of the present invention, each original text can be initially screened based on the structure of the newly added text and the structure of each original text, that is, the original text with a different structure from the new text can be filtered out. Further, based on the radicals of the newly added text and the filtered radicals of each original text, the morphologically close characters are selected. For example, the filtered original text with the same radical as the new text is determined as the morphologically close character. Another example is to determine the morphologically close characters. The M filtered original characters with the highest radical similarity to the newly added characters are determined to be closely related characters, where M is a positive integer. Or, first, based on the radicals of the newly added text and the radicals of each original text, filter out the original text that has the same radical as the new text, and then, based on the structure of the new text and the structure of each filtered original text, filter out If the structure of the original text is different from that of the newly added text, the filtered original text that has the same structure as the new text will be used as a close text.

[0086] For example, the newly added text is "Zai", and the original text includes "pregnancy", "grandson", "囝", "still", and "nan". Among them, the structure of "Zai" is a left-right structure, the structure of "Zheng" is an up-and-down structure, the structure of "Sun" is a left-right structure, the structure of "囝" is a fully enclosed structure, the structure of "Yi" is a left-right structure, and the structure of "Nan" is a left-right structure. "The structure is a left-right structure. Filter each original text according to the structure of the newly added text and the structure of each original text. The filtered original text includes "Sun", "Still", and "Nan". The radicals of "Zai" are "人" and "子", the radicals of "Sun" are "子" and "小", the radicals of "still" are "人" and "Nai", and the radicals of "Nan" are "木" ” and “南”, based on the radicals of the newly added text and the filtered The radicals of each original text are screened. Since "Sun" and "Zai" have the same radical "Zi", and "Still" and "Zai" have the same radical "人", then "Sun" and "Still" are both new The added character is a close-up character of "Zai".

[0087] In the second optional embodiment of the present invention, each original text can be initially screened according to the structure of the newly added text and the structure of each original text, that is, the original text with a different structure from the new text is filtered out, and we obtain At least one first backup text; further, for each radical of the newly added text, each first backup text is screened twice, and the first backup text with the radical is used as the second backup text; thereafter, from the newly added text From the second alternative text corresponding to each radical of the text, one alternative text is selected as the nearly morphological text. Or, first perform a preliminary screening of each original text for each radical of the newly added text, and use the original text with this radical as the first candidate text; then, based on the structure of the new text and the structure of each first candidate text, Perform a secondary screening on each first candidate text, that is, filter out the first candidate text that has a different structure from the newly added text, and obtain at least one second candidate text; further, select the second candidate text corresponding to each radical of the newly added text. Among the backup texts, one backup text is selected as the approximate text. It can be selected randomly or according to the preset selection rules.

[0088] For example, the new text is "Zai", and the original characters include "gestation", "grandson", "囝", "still", "nan", "子" and "廃". Among them, the structure of "Zai" is a left-right structure, the structure of "Zheng" is an up-and-down structure, the structure of "Sun" is a left-right structure, the structure of "囝" is a fully enclosed structure, the structure of "Yi" is a left-right structure, and the structure of "Nan" is a left-right structure. The structure of "" is a left-right structure, the structure of "子" is a left-right structure, and the structure of "仃" is a left-right structure. If each original text is filtered according to the structure of the newly added text and the structure of each original text, the first alternative text is "Sun", "Still", "Nan", "Zi" and "Ding". The radicals of "Zai" are "人" and "子", the radicals of "Sun" are "子" and "小", the radicals of "still" are "人" and "Nai", and the radicals of "Nan" are "木" " and "南", the radicals of "子" are "米" and "子", and the radicals of "ding" are "人" and "丁", for For each radical of the newly added word "izai", perform a second screening on each first alternative text to obtain the second alternative text "still" and "ding" corresponding to the first radical "人" in the newly added text "izai" ", as well as the second alternative characters "Sun" and "子" corresponding to the second radical "子". Choose one from "still" and "廃" as the metamorphic character, and choose one from "Sun" and "子" as the metamorphic character.

[0089] In the third optional embodiment of the present invention, the structure and radicals of the newly added characters, as well as the structure and radicals of each original character, can also be input into the pre-trained similarity calculation model, and the similarity calculation model outputs the new The text similarity between the text and each original text is increased, and then the similarity of each text is arranged from large to small, and the original text corresponding to the top K text similarity is determined as a similar text. Wherein, K is a positive integer, the similarity calculation model is trained based on multiple text pairs, and the text pairs carry text similarity labels.

[0090] Step 104: Input the text image of the newly added text and the text images of each similar text in the target image to a font generation network to generate the new text after font style migration.

[0091] Specifically, the text image of the new text refers to the image or picture of the new text input by the user in a standard font, such as an image of the Song-style character "I". A text image that is close to a text refers to an image in the target image that is close to the area corresponding to the text.

[0092] Font style migration refers to converting a font of one style (generally a standard style font) into a font of another style (target style), such as converting Song font to Kai font.

[0093] The font generation network refers to a network that can perform font style transfer and text generation, such as converting the character "kai" in Song style into the character "kai" in regular script. The font generation network can achieve artistic glyph image synthesis through single-stage few-shot learning. Network (Artistic Glyph Image Synthesis via One-Stage Few-Shot Learning, AGISNet), which can be a Conditional Generative Adversarial Nets, CGGAN), it can also be a deformable generative network for unsupervised font generation (Deformable Generative Networks for Unsupervised Font Generation, DGFONT), etc., and the present invention is not limited to this.

[0094] In practical applications, for new text, the text image of the new text in any font style can be obtained, and images of various shapes similar to the text can be obtained from the target image. Then input the text images of various similar-shaped characters and the text images of newly added characters into the font generation network. The font generation network extracts the font style features of each text image of similar-shaped characters, and based on the extracted font style features, the font style features are extracted. The text image of the newly added text undergoes font style feature migration to obtain a target text image containing the target text, where the target text is the newly added text after the font style migration.

[0095] It should be noted that, before inputting the text image of the newly added text and the text images of each similar text in the target image to the font generation network, and generating the new text after font style migration, it also includes: based on Multiple text image groups train the initial font generation network to obtain the target font generation network. into a network, wherein the text image group includes a training text image, a label text image and at least one font style image. The text in the font style image is different from the text in the label text image and has the same font style. The text in the training text image is the same as the label. Text images have the same text but different font styles.

[0096] Specifically, the initial font generation network is trained based on multiple text image groups to obtain the target font generation network. The process is as follows:

[0097] Obtain a training set and an initial font generation network, wherein the training set includes a plurality of text image groups, and the text image group includes a training text image, a label text image, and at least one font style image;

[0098] Extract a first text image group from the training set, input the at least one font style image and the training text image in the first text image group into the initial font generation network to obtain a predicted text image, The first text image group is any text image group;

[0099] Calculate a loss value based on the predicted text image and the label text image in the first text image group;

[0100] According to the loss value, the parameters of the initial font generation network are adjusted, and the step of extracting the first text image group from the training set is continued until the preset stop condition is reached, and a trained target font generation network is obtained.

[0101] Among them, there are many loss functions for calculating loss values, which can be loss functions based on distance measures, such as mean squared error loss function (Mean Squared Error, MSE), L1 loss function (Manhattan distance), L2 loss function (Euclidean distance ), etc., can be a loss function based on probability distribution measurement, such as KL divergence function (relative entropy), cross-entropy loss function, softmax loss function, etc. The preset stop condition may be that the number of iterations reaches the iteration threshold, the loss value is less than the loss threshold, or the number of iterations reaches the iteration threshold and the loss value is less than the loss threshold, etc.

[0102] On the basis of obtaining the new text after the font style migration, the new text after the font style migration can be added to the target image to realize the editing of the text content of the target image and ensure the overall text content in the target image. Consistent style.

[0103] The font generation method provided by the present invention determines the closely related characters corresponding to the newly added characters through the structure and radicals, so that the radicals of the newly added characters can appear in the text pictures of the similar characters, which is conducive to the font generation network to migrate the style of the radicals. When adding new text, the final generation effect is close to the overall style of the target image, which is simple and efficient, and improves the overall effect of font generation.

[0104] Illustratively, the font generation method is explained by taking a small-shot font generation network with multiple localization experts, namely mxfont, as an example. See Figure 2 , Figure 2 is a schematic structural diagram of the font generation network provided by the present invention: the mxfont network includes multi-head encoders (Multi Localized Experts), such as E 1 to E k As shown, each encoder extracts features from the input text image to obtain text features (Local features), that is, each encoder outputs a feature, such as f 1 to f k .

[0105] Let "I" be the newly added text and "Oh" be the font of similar shape. The first text image (the text image corresponding to "I" on the left) is input into the multi-head encoder for feature extraction, and the "I" in the first text image is obtained. "Text characteristics ( Figure 2 f in upper middle part 1 to f k ), where each literal feature of "I" contains two sub-features: the first sub-style feature and the first sub-content feature, such as f 1 including f s,1 and f c,1 ,f k including f s,k and f c,k . Combine each first sub-style feature to obtain the first style feature, such as f s,1 to f s,k Combine, combine each first sub-content feature to obtain the first content feature, such as f c,1 to f c,k Make a combination.

[0106] Correspondingly, the second text image (the text image corresponding to "oh") is input into the multi-head encoder for feature extraction, and the text features of "oh" in the second text image ( Figure 2 f in the middle and lower half 1 to f k ), where each text feature of "oh" also contains two sub-features: the second sub-style feature and the second sub-content feature, such as f 1 including f s`,1 and f c`,1 ,f k including f s`,k and f c`,k . Combine each second sub-style feature to obtain the second style feature, such as f s`,1 to f s`,k Combine each second sub-content feature to obtain the second content feature, such as f c`,1 to f c`,k Make a combination.

[0107] Then, the first content feature and the second style feature are concatenated (concat) and input into the generator (Generator, G) to obtain the third text image (the "I" on the right, which is the new text after the font style migration) .

[0108] In an optional embodiment of the present invention, the newly added characters can be matched with each original character based only on the structure and radicals, and at least one similar character can be selected from each original character. In this way, while ensuring less data processing volume, the efficiency and accuracy of font generation can be improved.

[0109] In another optional embodiment of the present invention, since a text with a greater number of strokes will have richer local style features, text for reference can also be selected based on the number of strokes. That is to say, before inputting the text image of the newly added text and the text images of each similar text in the target image to the font generation network, it also includes:

[0110] Find the stroke number of each original text according to the semantic information;

[0111] Determine the original text whose number of strokes meets the preset stroke conditions as the stroke reference text;

[0112] Correspondingly, inputting the text image of the newly added text and the text images similar to the text in the target image to the font generation network includes:

[0113] The text image of the newly added text, the text image of each similar text in the target image, and the text image of each stroke reference text are input to the font generation network.

[0114] Specifically, the number of strokes refers to the number of uninterrupted points and lines of various shapes that make up a Chinese character. Preset stroke conditions refer to stroke-related conditions preset for filtering stroke reference text.

[0115] In practical applications, for each original text, the entity of the original text can be determined based on the semantic information of the original text, and the strokes of the original text can be identified based on the entity of the original text, and the number of strokes can be counted, or the original text can be directly found. The number of strokes in the original text. Traverse each original text and obtain the number of strokes of each original text.

[0116] Further, the number of strokes of each original text is compared with the preset stroke conditions to determine the stroke reference text. Among them, the preset stroke condition can be to determine the original text with a number of strokes greater than the stroke threshold as the stroke reference text; it can also be to determine the S original text with the largest number of strokes as the stroke reference text, and S is a natural number. For example, after determining After the number of strokes of the original text, the number of strokes is arranged from large to small, and the original text corresponding to the top S stroke numbers is determined as the stroke reference text.

[0117] Correspondingly, the text image of the stroke reference text determined based on the number of strokes, the text image of the shape-near reference text (shape-near text) determined based on the structure and radicals, and the text image of the newly added text can be input to the font generation network for processing .

[0118] In this way, by using stroke reference text with a larger number of strokes, the text generation network can obtain richer font style features, so that when the text generation network generates new text after font migration, the accuracy is higher and the font is guaranteed The style of the newly migrated text and the reference text (stroke reference text and similar characters) in the target image are consistent, improving the efficiency of font generation.

[0119] It should be noted that in order to avoid the overlap between stroke reference text with a large number of strokes and closely related characters determined using radicals and structures, when determining the original text whose number of strokes meets the preset stroke conditions as a stroke reference text, you can first Extract the non-morphologically similar characters in each original text, that is, eliminate the closely related characters in each original text that are determined based on radicals and structures, and then determine the original characters in the non-morphologically similar characters whose number of strokes meets the preset stroke conditions as stroke reference characters. .

[0120] See Figure 3 , Figure 3 It is a schematic diagram of the processing flow of the font generation network provided by the present invention: input the text image of the reference text (such as Che, Xi, Zhe and Teng, where Che and Zhe are close-shaped characters, and Xi and Teng are stroke reference characters) into the font generation The reference image receiving layer of the network inputs the text image of the newly added text (such as the withdrawal on the left) to the new image receiving layer of the font generation network. After processing by the font generation network, the target image (such as the withdrawal on the right) is output, where The target image displays the new text after the font style migration.

[0121] In addition, you can also directly replace "according to the structure and the radical, match the new characters with each of the original characters, and filter out at least one similar character from each of the original characters" with " Search the number of strokes of each original text according to the semantic information; determine the original text whose number of strokes meets the preset stroke conditions as a stroke reference text", and Replace "Input the text image of the newly added text and the text images of each similar text in the target image to the font generation network to generate the new text after font style migration" with "Input the newly added text The text image of the text and the text image of the reference text for each stroke in the target image are input to the font generation network, and the new text after the font style migration is generated." Using the original text with a larger number of strokes alone as the reference text can improve the efficiency and accuracy of font generation while ensuring less data processing.

[0122] In one or more optional embodiments of the present invention, according to the structure and the radicals, the new words are matched with the original words respectively, and the new words are filtered from the original words. Produce at least one similar word. The specific implementation process can be as follows:

[0123] Screen at least one alternative text from each of the original texts, and the structure of the alternative text is the same as the structure of the new text;

[0124] For each candidate text, compare the radicals of the candidate text and the radicals of the new text to determine the number of identical radicals of the candidate text and the new text;

[0125] The candidate character with the largest number of same radicals is determined as the first closely related character.

[0126] Specifically, the first nearly morphological character refers to the nearly morphological character that has the closest glyph structure of each original character and the newly added character, that is, the morphologically similar character that has the same structure as each original character and the newly added character and has the most identical radicals.

[0127] In practical applications, each original text can be initially screened based on the structure of the new text and the structure of each original text, that is, the original text with a different structure from the new text is filtered out to obtain at least one candidate text; further, For each candidate text, identify the radicals in the candidate text that are the same as each reference radical, that is, the same radical, and count the number of identical radicals, where the reference radical is the radical of the newly added text. Traverse each alternative text and obtain the number of identical radicals corresponding to each alternative text. Then, the first Q candidate characters with the largest number of identical radicals are determined as the first closely related characters, and Q is a positive integer. Preferably, in order to ensure the generation effect and reduce the amount of data processing, the candidate character with the largest number of identical radicals can be determined as the first closely related character.

[0128] For example, the new text is "Che", and the alternative words include "抷", "倷", "唷" and "风". Among them, the radicals of "Che" include "氵", "Yu" and "攵", the radicals of "婵" include "氵" and "fierce", and the radicals of "Zhe" include "Che", "Yu" and "攵" ", the radicals of "唷" include "口" and "优", and the radicals of "Fang" are "方" and "恵". Then the number of the same radicals of "娷" and "Che" is 1, the number of the same radicals of "Zhe" and "Che" is 2, the number of the same radicals of "唷" and "Che" is 1, and the number of "Fang" and "Che" The number of identical radicals is 1. Then "Zhe" is determined to be the first nearly morphological character.

[0129] In this way, the candidate characters with the same structure as the new text are first screened, and then the candidate text with the largest number of same radicals as the new text is selected as the first nearly morphological character. Since the first nearly morphological character has the same structure as the new text, And the number of the same radicals as the newly added text is the largest. When the font generation network generates the new text after the font migration style, it can provide the font generation network with more accurate font style characteristics, which is beneficial to improving the accuracy and reliability of text generation. sex.

[0130] In one or more optional embodiments of the present invention, after determining the candidate character with the largest number of same radicals as the first closely related character, the method further includes:

[0131] The candidate text containing the specified radical is determined as a second closely related character, and the specified radical is a radical included in the radical of the newly added character and not included in the radical of the first closely related character.

[0132] Specifically, the second closely related characters refer to the closely related characters in each original character that have the same structure as the newly added characters and have designated radicals.

[0133] In practical applications, on the basis of obtaining the first closely related script, it is further determined that the specified radicals included in the new character and not included in the first closely related script are determined, and then the candidate characters containing the specified radicals are determined as the second closely related characters. .

[0134] Following the above example, the new character is "Che", and the alternative characters include "抷", "瀷", "唷" and "风", among which "Zhe" is the first closely related character. Since "瀵" does not contain the radical "氵" in "Che", that is, "氵" is the designated radical, and "氵" does not contain "氵", so "戵" can be determined as the second close character.

[0135] Preferably, in order to ensure the generation effect and reduce the amount of data processing, when there are multiple candidate characters containing the specified radical, one candidate character containing the specified radical is selected as the second closely related character according to the filtering rules.

[0136] In this way, filtering out second closely related characters based on specified radicals can ensure that the font style of each radical of the newly added characters has a corresponding reference basis, which is beneficial to improving the accuracy and efficiency of font generation.

[0137] It should be noted that the angular character may include a first angular character, or may include a first morphological character and a second angular character.

[0138] In an optional embodiment of the present invention, the specific implementation process of obtaining the semantic information of the newly added text and the semantic information of each original text in the target image can be as follows:

[0139] Obtaining each text paragraph in the target image, each display text contained in each text paragraph, and the semantic information of each display text;

[0140] If a text adding operation for the target image is detected, the position information corresponding to the text adding operation, the new text and the semantic information of the new text are obtained;

[0141] Determine the target text paragraph corresponding to the position information;

[0142] Each displayed text included in the target text paragraph is determined as an original text.

[0143] Specifically, a text paragraph refers to a relatively independent part divided according to the content and stage of an article or thing. Display text refers to the text presented on the target image.

[0144] The text adding operation refers to the operation of adding text to the target image. The position information represents the position of the text in the target image, which can be coordinates. For example, in a coordinate system established with the upper left corner of the picture as the origin, the coordinates corresponding to the insertion position corresponding to the text addition operation are used as the position information corresponding to the text addition operation; also The insertion position corresponding to the text adding operation can be directly determined to correspond to the text paragraph in the target image and which word in the text paragraph precedes or follows the text adding operation to determine the position information corresponding to the text adding operation.

[0145] In practical applications, there can be multiple text paragraphs in the target image. In general, in order to highlight key content, the font styles of the characters in different text paragraphs may be different. For example, the font of the characters in the first paragraph is official script, and the font of the characters in the second paragraph is running script. Therefore, each displayed text in the paragraph corresponding to the position information corresponding to the text adding operation needs to be determined as the original text. Therefore, you can first obtain all text paragraphs in the target image, each displayed text contained in each text paragraph (such as the coordinates of each displayed text in the paragraph) and each displayed text through text line detection, OCR technology, single word detection, paragraph detection, etc. semantic information. When the user inserts new text at a certain position in the target image, correspondingly, subject detection is performed to add text to the target image, and the location information corresponding to the text addition operation, the new text, and the semantic information of the new text are identified; Or the text adding operation carries the location information, the new text, and the semantic information of the new text, and the text adding operation is parsed to obtain the location information, the new text, and the semantic information of the new text.

[0146] Further, the text paragraph at the position (insertion position) pointed to by the position information in the target image is determined as the target text paragraph. Correspondingly, each displayed text included in the target text paragraph is the original text.

[0147] In this way, the target text paragraph is determined based on the position information corresponding to the text addition operation, and each displayed text in the target text paragraph is determined as the original text. This determines the range of the original text and ensures to a great extent that the font style of the original text is The target font style of the new text is the font style of the new text after the font style migration. Further, it ensures that the style of the text content is unified after the target image is modified.

[0148] In another optional embodiment of the present invention, the specific implementation process of obtaining the semantic information of the newly added text and the semantic information of each original text in the target image can be as follows:

[0149] Obtain each text paragraph in the target image and each display text contained in each text paragraph;

[0150] If a text adding operation for the target image is detected, the location information and new text corresponding to the text adding operation are obtained;

[0151] Determine the target text paragraph corresponding to the position information;

[0152] Determine each displayed text contained in the target text paragraph as original text respectively;

[0153] Obtain the semantic information of each original text and the semantic information of the newly added text.

[0154] In practical applications, all text paragraphs in the target image and each displayed text contained in each text paragraph (such as the coordinates of each displayed text in the paragraph) can be obtained first through text line detection, OCR technology, single word detection, paragraph detection, etc. When the user inserts new text at a certain position of the target image, correspondingly, the subject detection is performed to add text to the target image, and the location information corresponding to the text addition operation and the new text are identified; or the text addition operation carries the location information and add new text, and parse the text addition operation to obtain the location information and new text.

[0155] Further, the text paragraph at the position (insertion position) pointed to by the position information in the target image is determined as the target text paragraph. Correspondingly, each displayed text included in the target text paragraph is the original text. Then obtain the semantic information of each original text and the semantic information of the newly added text.

[0156] In this way, the original text is determined first, and then the semantic information of the original text is obtained. Compared with obtaining the semantic information of each displayed text of the target image, the amount of data acquisition is reduced. In addition, it is guaranteed to a great extent that the font style of the original text is the target font style of the newly added text, that is, the font style of the new text after the font style migration. Furthermore, it is ensured that the style of the text content is unified after the target image is modified. .

[0157] In one or more optional embodiments of the present invention, for each reference text (similar text, or similar text and stroke reference text), if the reference text only appears once in the target image, then it means that There is only one text image of the reference text in the target image, and the text image of the reference text in the target image can be directly input into the font generation network. If the reference text appears multiple times in the target image, it means that there are multiple text images of the reference text in the target image. You can directly input each text image of the reference text in the target image into the font generation network, or you can One text image is selected from each text image of the reference text and input into the font generation network.

[0158] Preferably, in order to improve the generation efficiency, the text image with the largest image size among the text images of the reference text can be input into the font generation network.

[0159] Illustratively, the reference text includes a text that is similar to the text, that is, before inputting the text image of the newly added text and the text images of each text that is similar to the text in the target image to the font generation network, it also includes:

[0160] For each character that is similar to the character, if there are multiple initial character images that are similar to the character in the target image, the initial character image with the largest image size is determined as the target character image that is similar to the character.

[0161] In practical applications, for each nearly-format character, if the nearly-format character appears multiple times in the target image, then there are multiple initial text images of the nearly-format character in the target image, and each initial text image of the nearly-format character is obtained. The image size of the image is compared, and the image size of each initial text image is compared, and the initial text image with the largest image size is determined as the target text image that is close to the text. It should be noted that the larger the image size, the larger the font size representing the text in the text image.

[0162] Illustratively, the reference text includes text that is similar to the text and reference text that is stroked, that is, the text image of the newly added text, the text image of each text that is similar to the text in the target image, and the text image of each stroke reference text are input. Before entering the font generation network, the method further includes: for each reference text, if there are multiple initial text images of the reference text in the target image, determine the initial text image with the largest image size as the reference text. The target text image, the reference text includes the shape-like text and the stroke reference text.

[0163] In this way, because the larger the text image, the higher the resolution of the text image and the less noise, the font style features are clearer, which not only improves the efficiency of the font generation network in identifying the font style features of the text image of the reference text, but also Improve the accuracy of recognition, thereby improving the accuracy and efficiency of font style transfer of new text by the font generation network, that is, improving the accuracy and efficiency of font generation.

[0164] In one or more optional embodiments of the present invention, radicals and structures of newly added characters, as well as radicals and structures of each original character, can be searched from the Internet based on semantic information. In this way, it is possible to avoid building a text information database for search, reduce the amount of data processing, and thereby improve the efficiency of font generation.

[0165] In one or more optional embodiments of the present invention, in order to avoid query interruption caused by network problems, radicals and structures can also be searched based on a pre-built text information database. That is to say, searching the radicals and structures of the newly added characters according to the semantic information, as well as the radicals and structures of each original character, include:

[0166] According to the semantic information of the newly added text, search the radicals and structures of the newly added text from a text information database, where the semantic information, radicals and structures of each text are stored in the text information database;

[0167] According to the semantic information of each original text, the radicals and structures of each original text are respectively searched from the text information database.

[0168] Specifically, the text information database, that is, the query table, contains information such as semantic information, radicals, and structures of multiple texts, and the radicals and structures are stored in association with the semantic information respectively.

[0169] In practical applications, a text information database can be built in advance. On the basis of obtaining the semantic information of each original text and the semantic information of the new text, according to the semantic information of the new text, the radicals and structure of the new text are searched from the text information database. For each original text, according to the Semantic information of the original text, find the radicals and structure of the original text from the text information database.

[0170] In this way, by searching for the radicals and structures of each original text and newly added text in the pre-built text information database, network interruption can be avoided, and the radicals and structures cannot be obtained from the network, which will lead to interruption of font generation and failure of font generation, that is By searching the radicals and structures of each original text and newly added text in the pre-built text information database, you can ensure the smooth progress of font generation.

[0171] In addition, the text information database can also store the number of strokes of each text, and the number of strokes is stored in association with the semantic information. Correspondingly, searching for the number of strokes of each original character according to the semantic information may be: for each original character, searching for the number of strokes of the original character according to the semantic information of the original character. In this way, network interruption can be avoided, and the number of strokes cannot be obtained from the network, which will lead to interruption of font generation and failure of font generation. That is, by searching the number of strokes of each original text in the pre-built text information library, the font generation can be smooth. To improve protection.

[0172] It should be noted that the text information database can store the semantic information, radicals, structure and number of strokes of common characters, and can also store the semantic information, radicals, structure and number of strokes of all characters. Referring to Table 1, Table 1 shows a text information database, which records more than 8,000 common Chinese characters (such as Hao, Jing, Jing, Guo, Si, Luo, Ge, Edit, Ji and Zhe). etc.) radicals, structure and number of strokes.

[0173] Table 1 Text information database

[0174]

[0175] For example, given a target picture to be edited, all text paragraphs in the target picture, as well as the text (single word) coordinates and each text in each text paragraph are obtained through text line detection, OCR technology, single word detection, paragraph detection, etc. Semantic information of the text, and then perform the following steps:

[0176] Step a: When inserting new text at a certain position (insertion position) of the target document, first find the target text paragraph at the insertion position, determine all the displayed text in the target text paragraph as the original text, and then according to the radicals and Structure, find the two similar characters A and B that are most similar to the new characters in each original text (if there are less than two characters, just take a few more strokes as reference characters in step b):

[0177] 1) According to the text information database, obtain the radicals, structure and number of strokes of each original text, as well as the radicals and structure of the newly added text. The structures here mainly include three types: upper (middle) lower structure, left (middle) right structure, and other structures. And store the structure information in the dictionary, the dictionary format is such as {'left and right': [Hao Hao...], 'Shang Xia': [Waiting Da...], 'Other': [Guo Guo...]};

[0178] 2) For newly inserted text (new text), first select a text set with the same structure (at least one alternative text), and then find the form that has the most radicals with the inserted word from at least one alternative text according to the radical composition. The closest character (the first nearly literal character), and then find the closest literal character (the second closest character) that has the same number of remaining radicals (specified radicals) from at least one candidate character. Example: The new text is "remove", and the set of characters with the same structure is {Che, 好, fold, Kuai, Mei}. First, find the first close-up word "Che" with the most identical radicals, and then the rest that need to be found The structure is "扌", so the second close character found later is "Zhe".

[0179] Step b: Sort the number of strokes of all the words in the target paragraph according to the text information database, and select the two words C and D with the most strokes except A and B as the stroke reference text.

[0180] Step c: Select the text images of the four characters A, B, C and D as the style map of the target generation network and input it to the font generation network, and input the text image of the new text into the font generation network to obtain font style migration New text after. If there are multiple text images for a reference text (any one of A, B, C and D), choose the one with the largest size. This is because in the scanned document, the larger the text image, the larger the resolution. The higher and the less noise.

[0181] In addition, since the present invention modifies the selection of the text image (style image) of the text used for reference when doing inference, it does not affect the training of the model. Therefore, the present invention can be applied to all font generation networks.

[0182] In this way, by combining the sorting of stroke numbers and the method of searching for radicals and structural similarities, the reference text (similar text and stroke reference text) and the text image (style map) to be sent to the font generation network are selected. For any font generation The Internet can improve the effect of font generation. The more strokes the stroke reference text has, the richer its local style features will be, and a certain radical of the generated text appears in a text image that is similar to the text, which is more conducive to the font generation network to transfer the style of the radical to the generated text. The text makes the final generated effect more similar, so simple and efficient, and improves the overall effect of font generation.

[0183] In order to highlight the effectiveness of the present invention, a comparative test was conducted. For the test results, see Figure 4 , Figure 4 It is a schematic diagram of the effect of the font generation method provided by the present invention. Among them, method one uses text with a smaller number of strokes as reference text (such as two and one) to generate new text (such as you, good, office and public); method two uses text with a larger number of strokes as reference text. (such as Jing, Lan, Yue and Ke), add new text (such as you, good , office and public); method three is the font generation method provided by the present invention, using two characters similar to the newly added characters (near-shaped characters) and two characters with a larger number of strokes (stroke reference characters) as Refer to the text to generate new text, such as using "servant" and "Mi" is used as the form of the new word "you", "Xi" and "Teng" are used as the stroke reference words of the new word "you"; "Zi" and "姝" are used as the form of the new word "好" In recent words, "Xi" and "Teng" are used as reference characters for the strokes of the new word "好"; use " "Li" and "Shao" are added as the form-like characters of "Ban", and "Xi" and "Teng" are used as stroke reference characters for the new character "Ban"; "Xi" and "Yun" are used as the new characters of "公" The shape of "" is close to the Chinese character, and "Xi" and "Teng" are used as reference characters for the strokes of the new character "公". From the comparison, it can be seen that the detailed features of characters generated by method two are obviously richer than those generated by method one, and the detailed features of characters generated by method three are obviously richer than those generated by method two, indicating that The font generation method provided by the present invention has excellent effects.

[0184] The font generation device provided by the present invention will be described below. The font generation device described below and the font generation method described above can be referenced correspondingly.

[0185] Figure 5 is a schematic structural diagram of the font generation device provided by the present invention, such as Figure 5 As shown, the font generation device 500 includes: an acquisition module 501, a search module 502, a filtering module 503 and a generation module 504, wherein:

[0186] The acquisition module 501 is configured to acquire the semantic information of the newly added text and the semantic information of each original text in the target image;

[0187] The search module 502 is configured to search for the radicals and structures of the newly added characters and the radicals and structures of each original character according to the semantic information;

[0188] The screening module 503 is configured to match the newly added characters with the original characters respectively according to the structure and the radicals, and filter out at least one similar character from each of the original characters;

[0189] The generation module 504 is configured to input the text image of the newly added text and the text images of each similar text in the target image to the font generation network, and generate the new text after font style migration.

[0190] The font generation device provided by the present invention determines the reference text corresponding to the newly added text through the structure and radicals, so that the radicals of the newly added text can appear in text pictures that are similar to the text, which is beneficial to the font generation network in migrating the style of the radical to Adding new text makes the final generation effect close to the overall style of the target image, which is simple and efficient, and improves the overall effect of font generation.

[0191] Optionally, the search module 502 is also configured to:

[0192] Find the stroke number of each original text according to the semantic information;

[0193] The screening module 503 is also configured to:

[0194] Determine the original text whose number of strokes meets the preset stroke conditions as the stroke reference text;

[0195] Correspondingly, the generation module 504 is further configured as:

[0196] The text image of the newly added text, the text image of each similar text in the target image, and the text image of each stroke reference text are input to the font generation network.

[0197] Optionally, the screening module 503 is further configured as:

[0198] Screen at least one alternative text from each of the original texts, and the structure of the alternative text is the same as the structure of the new text;

[0199] For each candidate text, compare the radicals of the candidate text and the radicals of the new text to determine the number of identical radicals of the candidate text and the new text;

[0200] The candidate character with the largest number of same radicals is determined as the first closely related character.

[0201] Optionally, the screening module 503 is further configured as:

[0202] The candidate text containing the specified radical is determined as a second closely related character, and the specified radical is a radical included in the radical of the newly added character and not included in the radical of the first closely related character.

[0203] Optionally, the acquisition module 501 is further configured as:

[0204] Obtaining each text paragraph in the target image, each display text contained in each text paragraph, and the semantic information of each display text;

[0205] If a text adding operation for the target image is detected, the position information corresponding to the text adding operation, the new text and the semantic information of the new text are obtained;

[0206] Determine the target text paragraph corresponding to the position information;

[0207] Each displayed text included in the target text paragraph is determined as an original text.

[0208] Optionally, the acquisition module 501 is further configured as:

[0209] Obtain each text paragraph in the target image and each display text contained in each text paragraph;

[0210] If a text adding operation for the target image is detected, the location information and new text corresponding to the text adding operation are obtained;

[0211] Determine the target text paragraph corresponding to the position information;

[0212] Determine each displayed text contained in the target text paragraph as original text;

[0213] Obtain the semantic information of each original text and the semantic information of the newly added text.

[0214] Optionally, the device further includes a determining module configured to:

[0215] For each character that is similar to the character, if there are multiple initial character images that are similar to the character in the target image, the initial character image with the largest image size is determined as the target character image that is similar to the character.

[0216] Optionally, the search module 502 is further configured as:

[0217] According to the semantic information of the newly added text, search the radicals and structures of the newly added text from a text information database, where the semantic information, radicals and structures of each text are stored in the text information database;

[0218] According to the semantic information of each original text, the radicals and structures of each original text are respectively searched from the text information database.

[0219] Optionally, the device further includes a training module configured to:

[0220] Obtain a training set and an initial font generation network, wherein the training set includes a plurality of text image groups, and the text image group includes a training text image, a label text image, and at least one font style image;

[0221] Extract a first text image group from the training set, input the at least one font style image and the training text image in the first text image group into the initial font generation network to obtain a predicted text image, The first text image group is any text image group;

[0222] Calculate a loss value based on the predicted text image and the label text image in the first text image group;

[0223] According to the loss value, the parameters of the initial font generation network are adjusted, and the step of extracting the first text image group from the training set is continued until the preset stop condition is reached, and a trained target font generation network is obtained.

[0224] Figure 6 This example illustrates the physical structure diagram of an electronic device, such as Figure 6 As shown, the electronic device may include: a processor (processor) 610, a communication interface (Communications Interface) 620, a memory (memory) 630, and a communication bus 640, wherein the processor 610, the communication interface 620, and the memory 630 pass through the communication bus 640. complete mutual communication. The processor 610 can call logical instructions in the memory 630 to execute a font generation method. The method includes: obtaining the semantic information of the newly added text and the semantic information of each original text in the target image; and searching for the newly added text according to the semantic information. The radicals and structures of the characters, as well as the radicals and structures of the original characters; according to the The above-mentioned structure and the radicals are matched with each of the original words respectively, and at least one similar word is selected from each of the original words; the text image of the new words and the described Text images of various shapes similar to text in the target image are input to the font generation network to generate the new text after font style migration.

[0225] In addition, the above-mentioned logical instructions in the memory 630 can be implemented in the form of software functional units and can be stored in a computer-readable storage medium when sold or used as an independent product. Based on this understanding, the technical solution of the present invention essentially or the part that contributes to the existing technology or the part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium, including Several instructions are used to cause a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in various embodiments of the present invention. The aforementioned storage media include: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), magnetic disk or optical disk and other media that can store program code. .

[0226] On the other hand, the present invention also provides a computer program product. The computer program product includes a computer program. The computer program can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can Execute the font generation method provided by each of the above methods. The method includes: obtaining the semantic information of the newly added text and the semantic information of each original text in the target image; searching according to the semantic information. Find the radicals and structures of the newly added characters, as well as the radicals and structures of each of the original characters; match the newly added characters with each of the original characters according to the structure and the radicals, and start from the Screen out at least one similar-shaped character from each original text; input the text image of the newly added text and the text image of each similar-shaped character in the target image into a font generation network to generate the new newly added text after font style migration. Word.

[0227] In yet another aspect, the present invention also provides a non-transitory computer-readable storage medium on which a computer program is stored. The computer program is implemented when executed by a processor to execute the font generation method provided by each of the above methods. The method includes: Obtain the semantic information of the newly added text and the semantic information of each original text in the target image; find the radicals and structure of the new text according to the semantic information, and the radicals and structures of each of the original characters; according to the structure and the radicals, the new characters are matched with each of the original characters, and at least one similar character is selected from each of the original characters. ; Input the text image of the newly added text and the text images of each similar text in the target image to the font generation network to generate the new text after font style migration.

[0228] The device embodiments described above are only illustrative. The units described as separate components may or may not be physically separated. The components shown as units may or may not be physical units, that is, they may be located in One location, or it can be distributed across multiple network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the solution of this embodiment. Persons of ordinary skill in the art can understand and implement the method without any creative effort.

[0229] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the part of the above technical solution that essentially contributes to the existing technology can be embodied in the form of a software product. The computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., including a number of instructions to cause a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in various embodiments or certain parts of the embodiments.

[0230] Finally, it should be noted that the above embodiments are only used to illustrate the technical solution of the present invention, but not to limit it; although the present invention has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that it can still be used Modifications may be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions may be made to some of the technical features; however, these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A font generation method, characterized in that: include: Obtaining semantic information of the newly added text and semantic information of each original text in the target image; Searching for the radical and structure of the newly added characters, and the radical and structure of each original character according to the semantic information; According to the structure and the radical, the newly added characters are matched with the original characters respectively, and at least one similar character is selected from the original characters; The text image of the newly added text and the text images of the similar characters in the target image are input into a font generation network to generate the newly added text after the font style is transferred.

2. The font generation method according to claim 1, characterized in that: Before inputting the text image of the newly added text and the text images of the similar texts in the target image into the font generation network, the method further includes: Searching for the number of strokes of each original character according to the semantic information; Determine the original character whose stroke number meets the preset stroke condition as the stroke reference character; Accordingly, the step of inputting the text image of the newly added text and the text images of the similar text in the target image into the font generation network includes: The character images of the newly added characters, the character images of the characters with similar shapes in the target image, and the character images of the characters with different strokes of the reference characters are input into a font generation network.

3. The font generation method according to claim 1 or 2, characterized in that: The step of matching the newly added characters with the original characters respectively according to the structure and the radicals, and selecting at least one similar character from the original characters, includes: Selecting at least one candidate character from each of the original characters, wherein the structure of the candidate character is the same as that of the newly added character; For each candidate character, compare the radical of the candidate character with the radical of the newly added character to determine the number of the same radicals between the candidate character and the newly added character; The alternative character with the largest number of identical radicals is determined as the first similar character.

4. The font generation method according to claim 3, characterized in that: After determining the candidate character with the largest number of identical radicals as the first similar character, the method further includes: The alternative characters containing the designated radical are determined as the second similar characters, wherein the designated radical is a radical included in the radicals of the newly added characters and not included in the radicals of the first similar characters.

5. The font generation method according to claim 1 or 2, characterized in that: The obtaining of semantic information of the newly added text and semantic information of each original text in the target image includes: Acquire each text paragraph in the target image, each display character contained in each text paragraph, and semantic information of each display character; If a text adding operation is detected for the target image, obtaining position information corresponding to the text adding operation, the newly added text, and semantic information of the newly added text; Determine a target text paragraph corresponding to the position information; Each displayed character contained in the target text paragraph is determined as the original character.

6. The font generation method according to claim 1 or 2, characterized in that: The obtaining of semantic information of the newly added text and semantic information of each original text in the target image includes: Acquire each text paragraph in the target image and each displayed word contained in each text paragraph; If a text adding operation is detected for the target image, obtaining position information and newly added text corresponding to the text adding operation; Determine a target text paragraph corresponding to the position information; Determine each displayed word contained in the target text paragraph as the original word; The semantic information of each original character and the semantic information of the newly added character are obtained.

7. The font generation method according to claim 1 or 2, characterized in that: Before inputting the text image of the newly added text and the text images of the similar texts in the target image into the font generation network, the method further includes: For each similar character, if there are multiple initial character images of the similar character in the target image, the initial character image with the largest image size is determined as the target character image of the similar character.

8. The font generation method according to claim 1 or 2, characterized in that: The searching for the radical and structure of the newly added characters and the radical and structure of each original character according to the semantic information includes: According to the semantic information of the newly added characters, searching for the radical and structure of the newly added characters from a character information database, wherein the character information database stores the semantic information, radical and structure of each character; According to the semantic information of each original character, the radical and structure of each original character are searched from the character information database respectively.

9. The font generation method according to claim 1 or 2, characterized in that: Before inputting the text image of the newly added text and the text images of the similar texts in the target image into the font generation network to generate the newly added text after the font style transfer, the method further includes: Acquire a training set and an initial font generation network, wherein the training set includes a plurality of text image groups, and the text image groups include training text images, label text images, and at least one font style image; Extracting a first text image group from the training set, inputting the at least one font style image in the first text image group and the training text image into the initial font generation network to obtain a predicted text image, wherein the first text image group is any text image group; Calculating a loss value according to the predicted text image and the label text image in the first text image group; According to the loss value, the parameters of the initial font generation network are adjusted, and the step of extracting the first text image group from the training set is continued until a preset stop condition is reached to obtain a trained target font generation network.

10. A font generation device, characterized in that: include: An acquisition module, configured to acquire semantic information of the newly added text and semantic information of each original text in the target image; A search module configured to search for the radical and structure of the newly added characters, and the radical and structure of each original character according to the semantic information; A screening module is configured to match the newly added characters with the original characters respectively according to the structure and the radicals, and screen out at least one similar character from the original characters; The generation module is configured to input the text image of the newly added text and the text images of each similar text in the target image into the font generation network to generate the newly added text after the font style is transferred.

Citation Information

Cited By

  • Personalized Chinese font generation method based on characters with similar shapes

    CN122573685A