CN113627124A - Processing method and device for font migration model and electronic equipment - Google Patents

Processing method and device for font migration model and electronic equipment Download PDF

Info

Publication number
CN113627124A
CN113627124A CN202010381723.6A CN202010381723A CN113627124A CN 113627124 A CN113627124 A CN 113627124A CN 202010381723 A CN202010381723 A CN 202010381723A CN 113627124 A CN113627124 A CN 113627124A
Authority
CN
China
Prior art keywords
image
font
migration
character
target
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202010381723.6A
Other languages
Chinese (zh)
Inventor
黄耀雄
何梦超
王永攀
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Alibaba Group Holding Ltd
Original Assignee
Alibaba Group Holding Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Alibaba Group Holding Ltd filed Critical Alibaba Group Holding Ltd
Priority to CN202010381723.6A priority Critical patent/CN113627124A/en
Publication of CN113627124A publication Critical patent/CN113627124A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/103Formatting, i.e. changing of presentation of documents
    • G06F40/109Font handling; Temporal or kinetic typography
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/22Matching criteria, e.g. proximity measures

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • Artificial Intelligence (AREA)
  • General Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • Bioinformatics & Cheminformatics (AREA)
  • Evolutionary Computation (AREA)
  • Evolutionary Biology (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Bioinformatics & Computational Biology (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Health & Medical Sciences (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • Computational Linguistics (AREA)
  • General Health & Medical Sciences (AREA)
  • Controls And Circuits For Display Device (AREA)
  • Character Discrimination (AREA)

Abstract

The application provides a processing method for a font migration model, which comprises the following steps: inputting a sample character image and a target font image into a current font migration model to be trained to obtain a target font migration image corresponding to the sample character image, wherein the current font migration model to be trained is used for obtaining a font migration image corresponding to the character image according to the character image and the target font image; acquiring a character radical block diagram corresponding to characters in the target font migration image, and acquiring a character radical block diagram corresponding to the characters in the target font image; and if the fonts in the character radical block diagram corresponding to the characters in the target font migration image are matched with the fonts in the character radical block diagram corresponding to the characters in the target font image, taking the current font migration model to be trained as a target font migration model. The processing method for the font migration model improves the font migration effect of the target font characters and the target digital images.

Description

Processing method and device for font migration model and electronic equipment
Technical Field
The present application relates to the field of computer technology. The present application relates to a processing method for a font migration model, and also relates to a processing apparatus, an electronic device, and a storage medium for a font migration model.
Background
The deep learning model has been widely used in the fields of character recognition, image recognition, and voice recognition as a new research direction in the field of machine learning. At present, the accuracy of the deep learning model is closely related to model training data, however, model training data for training the deep learning model often has a very small amount of training data of some rare categories, or even no training data, which is a catastrophic problem for training the deep learning model, for example: model training data for deep learning models for text recognition typically has a long tail effect. In order to improve the accuracy of the deep learning model for text recognition, the text training images are often required to be synthesized, and in order to ensure that the synthesized text training images have better representation capability, related personnel often use font migration to make the synthesized text training images be text training images with target fonts, so that the synthesized text training images are closer to actual text data.
At present, in the existing method for synthesizing text and images of a target font through font migration, a font migration method based on a radical is used for characters with complex structures, such as: chinese. However, the existing font migration method based on the radical can only divide the radical in a general way, that is, the characters are divided into an upper part and a lower part as the radical in a general way, or the left part and the right part as the radical, and the accurate position of the radical cannot be accurately found, so that the font migration effect of the target font characters and images is poor.
Disclosure of Invention
The application provides a processing method and device for a font migration model, an electronic device and a storage medium, so as to improve the font migration effect of a target font text and image.
The application provides a processing method for a font migration model, which comprises the following steps:
inputting a sample character image and a target font image into a current font migration model to be trained to obtain a target font migration image corresponding to the sample character image, wherein the current font migration model to be trained is used for obtaining a font migration image corresponding to the character image according to the character image and the target font image;
acquiring a character radical block diagram corresponding to characters in the target font migration image, and acquiring a character radical block diagram corresponding to the characters in the target font image;
and if the fonts in the character radical block diagram corresponding to the characters in the target font migration image are matched with the fonts in the character radical block diagram corresponding to the characters in the target font image, taking the current font migration model to be trained as a target font migration model.
Optionally, the method further includes:
if the font in the character radical block diagram corresponding to the characters in the target font migration image is not matched with the font in the character radical block diagram corresponding to the characters in the target font image, adjusting the parameters of the current font migration model to be trained to obtain a first font migration model;
taking the first font migration model as the current font migration model to be trained;
inputting a sample text image and the target font image into the current font migration model to be trained to obtain a first target font migration image corresponding to the sample text image;
acquiring a character radical block diagram corresponding to characters in the first target font migration image, and acquiring a character radical block diagram corresponding to characters in the target font image;
and if the font in the character radical block diagram corresponding to the characters in the first target font migration image is matched with the font in the character radical block diagram corresponding to the characters in the target font image, taking the current font migration model to be trained as a target font migration model.
Optionally, the method further includes: if the font in the character radical block diagram corresponding to the characters in the first target font migration image is not matched with the font in the character radical block diagram corresponding to the characters in the target font image, adjusting the parameters of the current font migration model to be trained to obtain a second font migration model, taking the second font migration model as the current font migration model to be trained, and so on until the target font migration model is obtained.
Optionally, the obtaining the radical block diagram of the character corresponding to the character in the target font migration image and obtaining the radical block diagram of the character corresponding to the character in the target font image include: and inputting the target font migration image and the target font image into a radical attention model, obtaining a character radical block diagram corresponding to characters in the target font migration image, and obtaining a character radical block diagram corresponding to the characters in the target font image, wherein the radical attention model is used for obtaining a character radical thermodynamic diagram corresponding to the characters in the font image according to the font image, and obtaining a character radical block diagram corresponding to the characters in the font image according to the character radical thermodynamic diagram corresponding to the characters in the font image.
Optionally, the method further includes:
obtaining a target radical block diagram;
aiming at a target radical block diagram, obtaining a sample font image and a character radical thermodynamic diagram corresponding to characters in the sample font image;
and obtaining the radical attention model according to the target radical block diagram, the sample font image and the character radical thermodynamic diagram corresponding to the characters in the sample font image.
Optionally, the inputting the target font migration image and the target font image into the radical attention model, obtaining a character radical block diagram corresponding to characters in the target font migration image, and obtaining a character radical block diagram corresponding to characters in the target font image, includes:
scaling the target font migration image and the target font image to a specified size;
performing feature extraction on the target font migration image with the specified size and the target font image with the specified size to obtain character image features corresponding to the target font migration image and character image features corresponding to the target font image;
acquiring a character radical thermodynamic diagram corresponding to the characters in the target font migration image and a character radical thermodynamic diagram corresponding to the characters in the target font image according to the character image characteristics corresponding to the target font migration image and the character image characteristics corresponding to the target font image;
and acquiring a character radical block diagram corresponding to the characters in the target font migration image according to the character radical thermodynamic diagram corresponding to the characters in the target font migration image and the character radical thermodynamic diagram corresponding to the characters in the target font image, and acquiring a character radical block diagram corresponding to the characters in the target font image.
Optionally, the performing feature extraction on the target font migration image with the specified size and the target font image with the specified size to obtain the text image feature corresponding to the target font migration image and the text image feature corresponding to the target font image includes: and extracting character outline image characteristics of the target font migration image with the specified size and the target font image with the specified size to obtain character outline image characteristics corresponding to the target font migration image and the target font image.
Optionally, the performing feature extraction on the target font migration image with the specified size and the target font image with the specified size to obtain the text image feature corresponding to the target font migration image and the text image feature corresponding to the target font image includes: and performing character stroke image feature extraction on the target font migration image with the specified size and the target font image with the specified size to obtain character stroke image features corresponding to the target font migration image and character stroke image features corresponding to the target font image.
Optionally, the obtaining a word radical thermodynamic diagram corresponding to the word in the target font migration image and a word radical thermodynamic diagram corresponding to the word in the target font image according to the word image feature corresponding to the target font migration image and the word image feature corresponding to the target font image includes:
carrying out average pooling on the character image characteristics corresponding to the target font migration image and the character image characteristics corresponding to the target font image to obtain one-dimensional character image characteristics corresponding to the target font migration image and one-dimensional character image characteristics corresponding to the target font image;
coding the one-dimensional character image characteristics corresponding to the target font migration image and the one-dimensional character image characteristics corresponding to the target font image to obtain the context coding characteristics of the character image corresponding to the target font migration image and the context coding characteristics of the character image characteristics corresponding to the target font image;
and acquiring a character radical thermodynamic diagram corresponding to the characters in the target font migration image and a character radical thermodynamic diagram corresponding to the characters in the target font image according to the context coding characteristics of the character image corresponding to the target font migration image and the context coding characteristics of the character image characteristics corresponding to the target font image.
Optionally, the obtaining a text radical thermodynamic diagram corresponding to the text in the target font migration image and a text radical thermodynamic diagram corresponding to the text in the target font image according to the context coding feature of the text image corresponding to the target font migration image and the context coding feature of the text image feature corresponding to the target font image includes:
obtaining probability distribution information corresponding to characters in the target font migration image and probability distribution information corresponding to characters in the target font image according to the context coding features of the character image corresponding to the target font migration image and the context coding features of the character image features corresponding to the target font image;
and acquiring a character radical thermodynamic diagram corresponding to the characters in the target font migration image and a character radical thermodynamic diagram corresponding to the characters in the target font image according to the probability distribution information corresponding to the characters in the target font migration image and the probability distribution information corresponding to the characters in the target font image.
Optionally, the obtaining, according to the text radical thermodynamic diagram corresponding to the text in the target font migration image and the text radical thermodynamic diagram corresponding to the text in the target font image, a text radical block diagram corresponding to the text in the target font migration image and a text radical block diagram corresponding to the text in the target font image includes: and acquiring a character radical block diagram corresponding to the characters in the target font migration image according to the context coding characteristics of the character image corresponding to the target font migration image, the context coding characteristics of the character radical thermodynamic diagram corresponding to the characters in the target font migration image and the character image characteristics corresponding to the target font image and the character radical thermodynamic diagram corresponding to the characters in the target font image.
Optionally, if the fonts in the character radical block diagram corresponding to the characters in the target font migration image are matched with the fonts in the character radical block diagram corresponding to the characters in the target font image, taking the current font migration model to be trained as the target font migration model, including: and if the matching degree of the fonts in the character radical block diagram corresponding to the characters in the target font migration image and the fonts in the character radical block diagram corresponding to the characters in the target font image is larger than or equal to a font matching degree threshold value, taking the current font migration model to be trained as a target font migration model.
Optionally, if the font in the radical block diagram corresponding to the text in the target font migration image is not matched with the font in the radical block diagram corresponding to the text in the target font image, adjusting the parameter of the current font migration model to be trained to obtain a first font migration model, including: and if the matching degree of the fonts in the character radical block diagram corresponding to the characters in the target font migration image and the fonts in the character radical block diagram corresponding to the characters in the target font image is smaller than the font matching degree threshold value, adjusting the parameters of the current font migration model to be trained, and obtaining a first font migration model.
Optionally, the method further includes: and obtaining the matching degree of the fonts in the character radical block diagram corresponding to the characters in the target font migration image and the fonts in the character radical block diagram corresponding to the characters in the target font image.
Optionally, the inputting the sample text image and the target font image into the current font migration model to be trained to obtain the target font migration image corresponding to the sample text image includes:
scaling the sample text image and the target font image to a preset size;
and obtaining a target font migration image corresponding to the sample text digital image according to the sample text image with the preset size and the target font image with the preset size.
In another aspect of the present application, a processing apparatus for a font migration model is provided, including:
a target font migration image obtaining unit, configured to input a sample text image and a target font image into a current font migration model to be trained, and obtain a target font migration image corresponding to the sample text image, where the current font migration model to be trained is configured to obtain a font migration image corresponding to the text image according to the text image and the target font image;
a character radical block diagram obtaining unit, configured to obtain a character radical block diagram corresponding to characters in the target font migration image, and obtain a character radical block diagram corresponding to characters in the target font image;
and the target font migration model obtaining unit is used for taking the current font migration model to be trained as the target font migration model if the fonts in the character radical block diagram corresponding to the characters in the target font migration image are matched with the fonts in the character radical block diagram corresponding to the characters in the target font image.
In another aspect of the present application, an electronic device is provided, including:
a processor; and
a memory for storing a program of a processing method for a font migration model, the apparatus performing the following steps after being powered on and running the program of the processing method for the font migration model by the processor:
inputting a sample character image and a target font image into a current font migration model to be trained to obtain a target font migration image corresponding to the sample character image, wherein the current font migration model to be trained is used for obtaining a font migration image corresponding to the character image according to the character image and the target font image;
acquiring a character radical block diagram corresponding to characters in the target font migration image, and acquiring a character radical block diagram corresponding to the characters in the target font image;
and if the fonts in the character radical block diagram corresponding to the characters in the target font migration image are matched with the fonts in the character radical block diagram corresponding to the characters in the target font image, taking the current font migration model to be trained as a target font migration model.
In another aspect of the present application, there is provided a storage medium storing a program of a processing method for a font migration model, the program being executed by a processor and performing the steps of:
inputting a sample character image and a target font image into a current font migration model to be trained to obtain a target font migration image corresponding to the sample character image, wherein the current font migration model to be trained is used for obtaining a font migration image corresponding to the character image according to the character image and the target font image;
acquiring a character radical block diagram corresponding to characters in the target font migration image, and acquiring a character radical block diagram corresponding to the characters in the target font image;
and if the fonts in the character radical block diagram corresponding to the characters in the target font migration image are matched with the fonts in the character radical block diagram corresponding to the characters in the target font image, taking the current font migration model to be trained as a target font migration model.
In another aspect of the present application, a font migration method is provided, including:
acquiring a character image to be processed and a target font image;
inputting the character image to be processed and the target font image into a radical block unit of a target font migration model, outputting a character radical block diagram corresponding to characters in the character image to be processed, and outputting a character radical block diagram corresponding to characters in the target font image, wherein the target font migration model is used for obtaining a font migration image corresponding to the character image according to the character image and the target font image;
and inputting the character radical block diagram corresponding to the characters in the character image to be processed and the character radical block diagram corresponding to the characters in the target font image into a font migration unit of the target font migration model, and outputting the target font migration image corresponding to the character image to be processed.
Optionally, the method further includes: and displaying the target font migration image.
Optionally, the obtaining the text image to be processed and the target font image includes: and acquiring the character image to be processed and the target font image provided by the client.
Optionally, the method further includes: and providing the designated target font migration image corresponding to the text image to be processed to the client.
In another aspect of the present application, a processing apparatus for a font migration model is provided, including:
the image obtaining unit is used for obtaining a character image to be processed and a target font image;
a character radical block diagram obtaining unit, configured to input the to-be-processed character image and the target font image to a radical block unit of a target font migration model, output a character radical block diagram corresponding to characters in the to-be-processed character image, and output a character radical block diagram corresponding to characters in the target font image;
a radical font migration image obtaining unit, configured to input a character radical cut-block diagram corresponding to characters in the to-be-processed character image and a character radical cut-block diagram corresponding to characters in the target font image into a font migration unit of the target font migration model, and obtain a target radical font migration image of a character radical corresponding to characters in the to-be-processed character image through font migration, where a font in the target radical font migration image matches a font in the character radical cut-block diagram corresponding to characters in the target font image;
and the target font migration image obtaining unit is used for assembling the target font radical migration images to obtain the target font migration images.
In another aspect of the present application, an electronic device is provided, including:
a processor; and
a memory for storing a program of a font migration method, the apparatus performing the following steps after being powered on and executing the program of the processing method for the font migration model by the processor:
acquiring a character image to be processed and a target font image;
inputting the character image to be processed and the target font image into a radical block unit of a target font migration model, outputting a character radical block diagram corresponding to characters in the character image to be processed, and outputting a character radical block diagram corresponding to the characters in the target font image;
inputting a character radical block diagram corresponding to characters in the character image to be processed and a character radical block diagram corresponding to characters in the target font image into a font migration unit of the target font migration model, and obtaining a target radical font migration image of the character radical corresponding to the characters in the character image to be processed through font migration, wherein fonts in the target radical font migration image are matched with fonts in the character radical block diagram corresponding to the characters in the target font image;
and assembling the target font radical migration image to obtain a target font migration image.
In another aspect of the present application, there is provided a storage medium storing a program for a font migration method, the program being executed by a processor and performing the steps of:
acquiring a character image to be processed and a target font image;
inputting the character image to be processed and the target font image into a radical block unit of a target font migration model, outputting a character radical block diagram corresponding to characters in the character image to be processed, and outputting a character radical block diagram corresponding to the characters in the target font image;
inputting a character radical block diagram corresponding to characters in the character image to be processed and a character radical block diagram corresponding to characters in the target font image into a font migration unit of the target font migration model, and obtaining a target radical font migration image of the character radical corresponding to the characters in the character image to be processed through font migration, wherein fonts in the target radical font migration image are matched with fonts in the character radical block diagram corresponding to the characters in the target font image;
and assembling the target font radical migration image to obtain a target font migration image.
In another aspect of the present application, a processing method for a font migration model is provided, including:
inputting a sample character image and a target font image into a current font migration model to be trained to obtain a target font migration image corresponding to the sample character image, wherein the current font migration model to be trained is used for obtaining a font migration image corresponding to the character image according to the character image and the target font image;
obtaining a character letter block diagram corresponding to the characters in the target font migration image, and obtaining a character letter block diagram corresponding to the characters in the target font image;
and if the fonts in the character letter block diagrams corresponding to the characters in the target font migration image are matched with the fonts in the character letter block diagrams corresponding to the characters in the target font image, taking the current font migration model to be trained as a target font migration model.
In another aspect of the present application, a font migration method is provided, including:
acquiring a character image to be processed and a target font image;
inputting the character image to be processed and the target font image into a radical block unit of a target font migration model, outputting a character letter block diagram corresponding to characters in the character image to be processed, and outputting a character letter block diagram corresponding to characters in the target font image;
inputting a character letter block diagram corresponding to characters in the character image to be processed and a character letter block diagram corresponding to characters in the target font image into a font migration unit of the target font migration model, and obtaining a target radical font migration image of the character letters corresponding to the characters in the character image to be processed through font migration, wherein fonts in the target radical font migration image are matched with fonts in the character letter block diagram corresponding to the characters in the target font image;
and assembling the target font radical migration image to obtain a target font migration image.
Compared with the prior art, the method has the following advantages:
the processing method for the font migration model includes the steps that firstly, a sample character image and a target font image are input into a current font migration model to be trained, and a target font migration image corresponding to a sample character image is obtained; then, acquiring a character radical block diagram corresponding to characters in the target font migration image, and acquiring a character radical block diagram corresponding to the characters in the target font image; and finally, if the fonts in the character radical block diagram corresponding to the characters in the target font migration image are matched with the fonts in the character radical block diagram corresponding to the characters in the target font image, taking the current font migration model to be trained as the target font migration model. The processing method for the font migration model can enable the target font migration model to explicitly divide the character radical block graph for processing, so that the character image to be processed is better subjected to font migration based on the character radicals, and the font migration effect of the target font character image is improved.
Drawings
Fig. 1 is a first schematic diagram of an application scenario of a processing method for a font migration model provided in the present application.
Fig. 1A is a first schematic diagram of an application scenario of a processing method for a font migration model provided in the present application.
Fig. 2 is a flowchart of a processing method for a font migration model provided in the first embodiment of the present application.
Fig. 3 is a flowchart of a method for obtaining a radical attention model according to a first embodiment of the present application.
Fig. 4 is a flowchart of a method for obtaining a radical block diagram in a first embodiment of the present application.
Fig. 5 is a schematic diagram of a processing apparatus for a font migration model provided in a second embodiment of the present application.
Fig. 6 is a schematic diagram of an electronic device provided in an embodiment of the present application.
Fig. 7 is a flowchart of a font migration method provided in a fifth embodiment of the present application.
Fig. 8 is a schematic diagram of a font migration apparatus provided in a sixth embodiment of the present application.
Detailed Description
In the following description, numerous specific details are set forth in order to provide a thorough understanding of the present application. This application is capable of implementation in many different ways than those herein set forth and of similar import by those skilled in the art without departing from the spirit of this application and is therefore not limited to the specific implementations disclosed below.
In order to more clearly show the processing method for the font migration model provided by the present application, an application scenario of the processing method for the font migration model provided by the present application is introduced first.
The processing method for the font migration model provided by the application is generally applied to an application scene for converting the characters in the character image to be processed into the designated target font. In an application scenario of the processing method for font migration models provided by the application, the characters are characters which are composed based on radicals and have complex structures, such as: chinese, Korean, Japanese, etc.; the target font is the standard of the font migration result and is used for indicating the font which is finally required to be transformed by the characters in the character picture to be processed; font migration is to convert characters in a character picture to be processed into a specified target font; the target font migration model is a font migration model which is obtained after model training is carried out on a large number of samples and meets preset conditions, wherein the preset conditions are that fonts in a character radical cut-off graph corresponding to characters in a font migration image obtained through the target font migration model are matched with fonts in a character radical cut-off graph corresponding to the characters in the target font image.
In an application scenario of the processing method for the font migration model provided by the application, a character radical is a basic component of a character, and is generally a character component cut according to a character structure, and a radical in a dictionary and the like correspond to the radical of the application. In an application scenario of the processing method for font migration model provided by the present application, a character radical block diagram is an image corresponding to a radical cut out from characters in a character image, such as: the character image corresponding to "ice" has character radical block diagrams corresponding to the image corresponding to the radical "" and the image corresponding to the radical "water", and the character image corresponding to "green", has character radical block diagrams corresponding to the image corresponding to the radical "green" and the image corresponding to the radical "er".
In an application scenario of the processing method for font migration models provided by the present application, an execution principal may be a server, or may be a client installed with relevant font migration applications, such as: a smartphone, a tablet Computer, a PC (Personal Computer), and the like are installed with the relevant font migration application. In the following, an application scenario applying for the processing method for the font migration model provided by the application is specifically described in detail by taking an execution subject as a server.
Fig. 1 is a first schematic diagram of an application scenario of a processing method for a font migration model provided in the present application.
After obtaining the character image 102 to be processed and the designated target font image 103, the server 101 inputs the character image 102 to be processed and the designated target font image 103 into the target font migration model, and obtains a designated target font migration image 104 corresponding to the character image to be processed.
In an application scenario of the processing method for the font migration model, the designated target font migration image corresponding to the text image to be processed is an image obtained by converting the font of the text in the text image to be processed into the font of the text in the designated target font image through the target font migration model with the designated target font image as a reference. In an application scenario of the processing method for font migration models provided by the present application, the target font image is generally a plurality of font images with the same font style that are designed in advance, and the characters in the target font image can be split into all or part of predetermined radicals that constitute the characters. In fig. 1, the font image corresponding to "his" is the designated target font image 103, however, the designated target font image 103 often includes a plurality of font images with the same pre-designed font style, in the embodiment of the present application, only the font image corresponding to "his" is used to represent the designated target font image 103, and the designated target font image 103 may further include a font image corresponding to "about" with the same font style as the font image corresponding to "he," a font image corresponding to "me," and a font image corresponding to "bao," and the like. It should be noted that, if the execution subject is not the server 101 but the client, after obtaining the designated target font migration image 104 corresponding to the text image to be processed, the client further displays the designated target font migration image corresponding to the text image to be processed. If the execution subject is the server 101, and the server 101 is according to the to-be-processed text image 102 and the designated target font image 103 provided by the client, then the server 101 further provides the designated target font migration image 104 corresponding to the to-be-processed text image to the client after obtaining the designated target font migration image corresponding to the to-be-processed text image.
In order to obtain a designated target font migration image corresponding to a text image to be processed through a target font migration model, in an application scenario of the processing method for a font migration model provided by the present application, training needs to be performed on the target font migration model first, and a specific training process refers to fig. 1A, which is a first schematic diagram of an application scenario of the processing method for a font migration model provided by the present application.
Firstly, inputting a sample text image and a target font image into a current font migration model to be trained 101A to obtain a target font migration image corresponding to the text image, wherein the current font migration model to be trained is used for obtaining a font migration image corresponding to the text image according to the text image and the target font image. Then, the target font migration image and the target font image are input into the character radical attention training model 102A, a character radical block diagram corresponding to the characters in the target font migration image is obtained, and a character radical block diagram corresponding to the characters in the target font image is obtained. Finally, the character radical block diagram corresponding to the characters in the target font migration image and the character radical block diagram corresponding to the characters in the target font image are input into a font judging module or a font judging device 103A, whether the fonts in the character radical block diagram corresponding to the characters in the target font migration image are matched with the fonts in the character radical block diagram corresponding to the characters in the target font image is judged, and if the fonts in the character radical block diagram corresponding to the characters in the target font migration image are matched with the fonts in the character radical block diagram corresponding to the characters in the target font image, the initial font migration model is used as the target font migration model.
In an application scenario of the processing method for font migration model provided in the present application, determining whether a font in the character radical tile map corresponding to the characters in the target font migration image matches a font in the character radical tile map corresponding to the characters in the target font image is determined by inputting the character radical tile map corresponding to the characters in the target font migration image and the character radical tile map corresponding to the characters in the target font image into a font determination module or a font determination device, and a specific process is as follows: and inputting the character radical block diagram body corresponding to the characters in the target font migration image and the character radical block diagram corresponding to the characters in the target font image into a font distinguishing module or a font discriminator to obtain the matching degree of the fonts in the character radical block diagram corresponding to the characters in the target font migration image and the fonts in the character radical block diagram corresponding to the characters in the target font image.
If the font in the character radical block diagram corresponding to the characters in the target font migration image is not matched with the font in the character radical block diagram corresponding to the characters in the target font image, adjusting the parameters of the current font migration model to be trained to obtain a first font migration model; taking the first font migration model as a current font migration model to be trained; inputting the sample character image and the target font image into a current font migration model to be trained to obtain a first target font migration image corresponding to the sample character image; acquiring a character radical block diagram corresponding to characters in a first target font migration image, and acquiring a character radical block diagram corresponding to the characters in the target font image; and if the font in the character radical block diagram corresponding to the characters in the first target font migration image is matched with the font in the character radical block diagram corresponding to the characters in the target font image, taking the current font migration model to be trained as the target font migration model. The process of judging whether the font in the character radical block diagram corresponding to the characters in the first target font migration image is matched with the font in the character radical block diagram corresponding to the characters in the target font image is also realized by a font judging module or a font discriminator.
And if the font in the character radical block diagram corresponding to the characters in the first target font migration image is not matched with the font in the character radical block diagram corresponding to the characters in the target font image, adjusting the parameters of the current font migration model to be trained to obtain a second font migration model, taking the second font migration model as the current font migration model to be trained, and repeating the steps until the target font migration model is obtained. In an application scenario of the processing method for the font migration model provided by the application, the process of determining the target font migration model is a process of continuously performing network countermeasure on the current font migration model to be trained and the body discrimination module or the font discriminator.
In an application scenario of the processing method for the font migration model, the sample character image is a pre-collected single character image, and specifically, the sample character image can be a single synthesized single character image synthesized by using an open source code and a single font; in an application scenario of the processing method for the font migration model, a target font migration image corresponding to the sample text digital image is an image obtained by converting the font of the characters in the sample text image into the font of the characters in the target font image through the initial font migration model with the target font image as a reference; the character radical block diagram is an image generated by splitting characters in an image according to radicals of the characters in the image.
It should be noted that the application scenario embodiment of the processing method for the font migration model provided in the present application is only one embodiment of the application scenario of the processing method for the font migration model provided in the present application, and the purpose of providing the application scenario embodiment is to facilitate understanding of the processing method for the font migration model provided in the present application, and is not to limit the processing method for the font migration model provided in the present application. The processing method for the font migration model provided by the application can also be applied to other application scenarios, the execution subject is not specifically limited, and the processing method for the font migration model provided by the application is applied to other application scenarios.
First embodiment
A processing method for a font migration model is provided in a first embodiment of the present application, which is described below with reference to fig. 2 to 4.
Please refer to fig. 2, which is a flowchart illustrating a processing method for a font migration model according to a first embodiment of the present application.
In step S201, the sample text image and the target font image are input into the current font migration model to be trained, so as to obtain a target font migration image corresponding to the sample text image, where the current font migration model to be trained is used to obtain a font migration image corresponding to the text image according to the text image and the target font image.
In the first embodiment of the present application, the text is a text composed based on radicals and having a complex structure, such as: although the characters such as chinese, korean, and japanese may also be characters with a simple structure such as english and latin, in general, english and latin do not need to perform font style migration through the font migration model provided in the first embodiment of the present application, and the characters may also be characters including characters with specific shapes, such as: inverted triangle characters, square characters, etc.; the sample character image is an image to be subjected to character migration, the sample character image is a single character image collected in advance, and specifically can be a single synthesized single character image synthesized by using an open source code and a single font; and converting the font of the characters in the sample character image into an image after the font of the characters in the target font image through the current font migration model to be trained by taking the target font image as a reference. The target font is a standard of a font migration result and is used for indicating the font which is finally required to be converted into by the characters in the character image to be processed; font migration is to transform the characters in the character image to be processed into a specified target font.
In the first embodiment of the present application, both the sample text image and the target font image may be partial images containing target text in a certain image, such as: and a local image corresponding to the characters in the landscape painting. The sample text image and the target font image may be images corresponding to video frames in the video.
In the first embodiment of the present application, inputting a sample text image and a target font image into a current font migration model to be trained to obtain a target font migration image corresponding to a sample text digital image includes: scaling the sample text image and the target font image to a preset size; and obtaining a target font migration image corresponding to the sample text digital image according to the sample text image with the preset size and the target font image with the preset size. The sample character image and the target font image are scaled to preset sizes, so that the size of each character of the image is relatively stable, and the calculated amount during image processing of the sample character image and the target font image is reduced.
In step S202, a character radical block diagram corresponding to the characters in the target font migration image is obtained, and a character radical block diagram corresponding to the characters in the target font image is obtained.
In the first embodiment of the present application, the character radical block diagram is an image generated by splitting characters in an image according to radicals of the characters in the image.
The process of obtaining the character radical block diagram corresponding to the characters in the target font migration image and obtaining the character radical block diagram corresponding to the characters in the target font image is as follows: and inputting the target font migration image and the target font image into a radical attention model, obtaining a character radical block diagram corresponding to characters in the target font migration image, obtaining a character radical block diagram corresponding to the characters in the target font image, wherein the radical attention model is used for obtaining a character radical thermodynamic diagram corresponding to the characters in the font image according to the font image, and obtaining a character radical block diagram corresponding to the characters in the font image according to the character radical thermodynamic diagram corresponding to the characters in the font image.
Since the radical attention model needs to be passed when obtaining the radical segmentation map corresponding to the characters in the target font migration image and obtaining the radical segmentation map corresponding to the characters in the target font image, in the first embodiment of the present application, a radical attention model needs to be obtained first, specifically please refer to fig. 3, which is a flowchart of a radical attention model obtaining method provided in the first embodiment of the present application.
Step S301: and obtaining a target radical block diagram.
Step S302: and aiming at the target radical block diagram, obtaining a sample font image and a character radical thermodynamic diagram corresponding to the characters in the sample font image.
Step S303: and obtaining a radical attention model according to the target radical block diagram, the sample font image and the character radical thermodynamic diagram corresponding to the characters in the sample font image.
In the first embodiment of the present application, a target font migration image and a target font image are input into a radical attention model, a text radical block diagram corresponding to characters in the target font migration image is obtained, and a detailed process of the text radical block diagram corresponding to the characters in the target font image is obtained, please refer to fig. 4, which is a flowchart of a text radical block diagram obtaining method provided in the first embodiment of the present application.
Step S401: the target font migration image and the target font image are scaled to a specified size.
And scaling the target font migration image and the target font image to the specified sizes, wherein the first purpose is to ensure that the size of each character of the image is relatively stable, and the second purpose is to reduce the calculation amount when the sample character image and the target font image are subjected to image processing.
Step S402: and performing feature extraction on the target font migration image with the specified size and the target font image with the specified size to obtain character image features corresponding to the target font migration image and character image features corresponding to the target font image.
In the first embodiment of the present application, performing feature extraction on a target font migration image with a specified size and a target font image with a specified size to obtain a text-image feature corresponding to the target font migration image and a text-image feature corresponding to the target font image includes: and extracting character outline image characteristics of the target font migration image with the specified size and the target font image with the specified size to obtain character outline image characteristics corresponding to the target font migration image and character outline image characteristics corresponding to the target font image.
In the first embodiment of the present application, the performing feature extraction on the target font migration image with the specified size and the target font image with the specified size to obtain the text image feature corresponding to the target font migration image and the text image feature corresponding to the target font image further includes: and extracting character stroke image characteristics of the target font migration image with the specified size and the target font image with the specified size to obtain character stroke image characteristics corresponding to the target font migration image and character stroke image characteristics corresponding to the target font image.
It should be noted that, the character stroke image feature extraction is performed on the target font migration image with the specified size and the target font image with the specified size, and the principle of the edge detection operator can be used. Character stroke image feature extraction is performed on the target font migration image with the specified size and the target font image with the specified size, and generally, character features such as edge features, connected regions, textures, projections and the like of characters are extracted. The stroke image feature extraction method comprises the following steps: dividing a target font image into a plurality of stroke subimages according to a preset character splitting rule, wherein the character splitting rule is a rule for indicating that a character is split into one or more strokes according to a character structure; secondly, extracting a skeleton map of the stroke parts from the plurality of stroke sub-images, finding out a cross point in the skeleton map, calculating a two-dimensional neighborhood midpoint trunk curve of the cross point in the binary image, and extracting a cross point region; extracting features of the stroke parts, and matching the features of the stroke parts to be extracted with the features of the stroke parts in the standard library; and fourthly, combining the stroke segments according to the matching result to obtain the stroke image characteristics.
Step S403: and acquiring a character radical thermodynamic diagram corresponding to the characters in the target font migration image and a character radical thermodynamic diagram corresponding to the characters in the target font image according to the character image characteristics corresponding to the target font migration image and the character image characteristics corresponding to the target font image.
In the first embodiment of the present application, the steps of obtaining the character radical thermodynamic diagram corresponding to the characters in the target font migration image and the character radical thermodynamic diagram corresponding to the characters in the target font image according to the character image features corresponding to the target font migration image and the character image features corresponding to the target font image are as follows: firstly, average pooling is carried out on character image features corresponding to the target font migration image and character image features corresponding to the target font image, and one-dimensional character image features corresponding to the target font migration image and one-dimensional character image features corresponding to the target font image are obtained. And then, coding the one-dimensional character image characteristics corresponding to the target font migration image and the one-dimensional character image characteristics corresponding to the target font image to obtain the context coding characteristics of the character image corresponding to the target font migration image and the context coding characteristics of the character image characteristics corresponding to the target font image. And finally, acquiring a character radical thermodynamic diagram corresponding to the characters in the target font migration image and a character radical thermodynamic diagram corresponding to the characters in the target font image according to the context coding characteristics of the character image corresponding to the target font migration image and the context coding characteristics of the character image characteristics corresponding to the target font image.
It should be noted that, according to the context coding features of the text image corresponding to the target font migration image and the context coding features of the text image features corresponding to the target font image, the process of obtaining the text radical thermodynamic diagram corresponding to the text in the target font migration image and the text radical thermodynamic diagram corresponding to the text in the target font image is as follows: first, according to the context coding feature of the text image corresponding to the target font migration image and the context coding feature of the text image feature corresponding to the target font image, probability distribution information corresponding to the text in the target font migration image and probability distribution information corresponding to the text in the target font image are obtained. And then, acquiring a character radical thermodynamic diagram corresponding to the characters in the target font migration image and a character radical thermodynamic diagram corresponding to the characters in the target font image according to the probability distribution information corresponding to the characters in the target font migration image and the probability distribution information corresponding to the characters in the target font image. Specifically, the method for obtaining a character radical block diagram corresponding to characters in a target font migration image and obtaining a character radical block diagram corresponding to characters in the target font image according to a character radical thermodynamic diagram corresponding to characters in the target font migration image and a character radical thermodynamic diagram corresponding to characters in the target font image includes: and acquiring a character radical block diagram corresponding to the characters in the target font migration image according to the context coding characteristics of the character image corresponding to the target font migration image, the context coding characteristics of the character radical thermodynamic diagram corresponding to the characters in the target font migration image and the character image characteristics corresponding to the target font image and the character radical thermodynamic diagram corresponding to the characters in the target font image.
In the first embodiment of the present application, taking obtaining a radical block diagram corresponding to a character in a target font migration image as an example, how to describe the radical block diagram, first, obtaining an activation value of a radical thermodynamic diagram of the character, and setting an activation value threshold according to the activation value of the radical thermodynamic diagram of the character, such as: 0.5; determining a mask corresponding to the character radical thermodynamic diagram according to the activation value of the character radical thermodynamic diagram, specifically, setting a point higher than a threshold value as 1, and setting a point lower than the threshold value as 0 to be used as the mask; and finally, obtaining a minimum external rectangular frame for each separated connected domain with the pixel of 1 on the mask, wherein the rectangular frame is the position of the character radical block diagram corresponding to the characters in the target character font migration image.
Step S404: and acquiring a character radical block diagram corresponding to the characters in the target font migration image according to the character radical thermodynamic diagram corresponding to the characters in the target font migration image and the character radical thermodynamic diagram corresponding to the characters in the target font image, and acquiring a character radical block diagram corresponding to the characters in the target font image.
In the first embodiment of the present application, obtaining a radical block diagram of characters corresponding to the characters in the target font migration image according to the radical thermodynamic diagram of the characters corresponding to the characters in the target font migration image and the radical thermodynamic diagram of the characters corresponding to the characters in the target font image, and obtaining a radical block diagram of the characters corresponding to the characters in the target font image includes: and acquiring a character radical block diagram corresponding to the characters in the target font migration image according to the context coding characteristics of the character image corresponding to the target font migration image, the context coding characteristics of the character radical thermodynamic diagram corresponding to the characters in the target font migration image and the character image characteristics corresponding to the target font image and the character radical thermodynamic diagram corresponding to the characters in the target font image.
After the character radical block diagram corresponding to the characters in the target font migration image is obtained and the character radical block diagram corresponding to the characters in the target font image is obtained, the matching degree between the fonts in the character radical block diagram corresponding to the characters in the target font migration image and the fonts in the character radical block diagram corresponding to the characters in the target font image needs to be obtained first, then whether the matching degree between the fonts in the character radical block diagram corresponding to the characters in the target font migration image and the fonts in the character radical block diagram corresponding to the characters in the target font image is larger than or equal to the font matching degree threshold value is judged, and different steps are executed according to the judgment result.
In step S203, if the font in the character radical block diagram corresponding to the character in the target font migration image matches the font in the character radical block diagram corresponding to the character in the target font image, the current font migration model to be trained is used as the target font migration model.
If the font in the character radical block diagram corresponding to the characters in the target font migration image is matched with the font in the character radical block diagram corresponding to the characters in the target font image, taking the current font migration model to be trained as the target font migration model, wherein the method comprises the following steps: and if the matching degree of the fonts in the character radical block diagram corresponding to the characters in the target font migration image and the fonts in the character radical block diagram corresponding to the characters in the target font image is larger than or equal to the font matching degree threshold value, taking the current font migration model to be trained as the target font migration model. Specifically, firstly, the matching degree of the fonts in the character radical block diagram corresponding to the characters in the target font migration image and the fonts in the character radical block diagram corresponding to the characters in the target font image is obtained; then, judging whether the matching degree of the fonts in the character radical block diagram corresponding to the characters in the target font migration image and the fonts in the character radical block diagram corresponding to the characters in the target font image is larger than or equal to a font matching degree threshold value or not; and if so, matching the fonts in the character radical block diagram corresponding to the characters in the target font migration image with the fonts in the character radical block diagram corresponding to the characters in the target font image.
It should be noted that, in order to ensure that the matching degree between the font in the character radical block diagram corresponding to the character in the target font migration image and the font in the character radical block diagram corresponding to the character in the target font image is high, a discriminant loss function L may be specifically usedgThe training of the matching degree of the fonts in the character radical block diagram corresponding to the characters in the target font migration image and the fonts in the character radical block diagram corresponding to the characters in the target font image is realized:
Figure BDA0002482240260000181
wherein, in order to ensure whether the matching degree between the font in the character radical block diagram corresponding to the characters in the target font migration image and the font in the character radical block diagram corresponding to the characters in the target font image is greater than or equal to the font matching degree threshold, one L may be used to determine whether the matching degree is greater than or equal to the font matching degree threshold2Loss function LPTo define the above training process: l isP=∑(Ωft)2
Figure BDA0002482240260000182
HiIth radical, I in character radical block diagramfFor font data corresponding to the target font image, ItMigrating font data corresponding to an image for a target font, DfThe probability that the matching degree is greater than or equal to the font matching degree threshold value is adopted, and AE is an auto-encoder.
If the matching degree of the fonts in the character radical block diagram corresponding to the characters in the target font migration image and the fonts in the character radical block diagram corresponding to the characters in the target font image is smaller than the font matching degree threshold value, adjusting the parameters of the current font migration model to be trained to obtain a first font migration model; taking the first font migration model as a current font migration model to be trained; . That is, if the font in the character radical block diagram corresponding to the characters in the target font migration image is not matched with the font in the character radical block diagram corresponding to the characters in the target font image, the parameters of the current font migration model to be trained are adjusted to obtain the first font migration model, and the first font migration model is used as the new current font migration model to be trained. After the second font migration model is obtained, in the first embodiment of the present application, the sample text image and the target font image are further input into a new font migration model to be trained, so as to obtain a first target font migration image corresponding to the sample text digital image. Then, a character radical block diagram corresponding to the characters in the first target font migration image is obtained, and a character radical block diagram corresponding to the characters in the target font image is obtained. Finally, if the font in the character radical block diagram corresponding to the characters in the first target font migration image is matched with the font in the character radical block diagram corresponding to the characters in the target font image, taking the new current font migration model to be trained as the target font migration model; or if the font in the character radical block diagram corresponding to the characters in the first target font migration image is not matched with the font in the character radical block diagram corresponding to the characters in the target font image, adjusting the parameters of a new current font migration model to be trained to obtain a second font migration model, taking the second font migration model as the current font migration model to be trained, and so on until the target font migration model is obtained.
In the first embodiment of the present application, after obtaining the target font migration model, the method further includes: and after the character image to be processed and the designated target font image are obtained, inputting the character image to be processed and the designated target font image into a target font migration model, and obtaining the designated target font migration image corresponding to the character image to be processed. The designated target font migration image corresponding to the text image to be processed is an image obtained by converting the font of the characters in the text image to be processed into the font of the characters in the designated target font image through the target font migration model by taking the designated target font image as a reference, and the font in the character radical cut-block diagram corresponding to the characters in the designated target font migration image is matched with the font in the character radical cut-block diagram corresponding to the characters in the designated target font image. Specifically, inputting the text image to be processed and the designated target font image into the target font migration model to obtain the designated target font migration image corresponding to the text image to be processed includes: inputting the character image to be processed and the appointed target font image into a target font migration model, obtaining a character radical block diagram corresponding to characters in the character image to be processed, and obtaining a character radical block diagram corresponding to the characters in the appointed target font image; and obtaining a designated target font migration image corresponding to the character image to be processed according to the character radical block diagram corresponding to the characters in the character image to be processed and the character radical block diagram corresponding to the characters in the designated target font image.
It should be noted that the above steps need to be supported by an execution main graph, where the execution main graph is generally a server, and may also be a client installed with a related font migration application, for example: and installing a related font migration application smart phone, a tablet personal computer, a PC and the like. If the execution main body is not the server side but the client side, after the specified target font migration image corresponding to the text image to be processed is obtained, the client side further displays the specified target font migration image corresponding to the text image to be processed. If the execution main body is the server and the server is according to the character image to be processed and the designated target font image provided by the client, the server further provides the designated target font migration image corresponding to the character image to be processed to the client after obtaining the designated target font migration image corresponding to the character image to be processed.
The first embodiment of the application provides a processing method for a font migration model, which comprises the steps of firstly, inputting a sample text image and a target font image into a current font migration model to be trained, and obtaining a target font migration image corresponding to the sample text digital image; then, acquiring a character radical block diagram corresponding to characters in the target font migration image, and acquiring a character radical block diagram corresponding to the characters in the target font image; and finally, if the fonts in the character radical block diagram corresponding to the characters in the target font migration image are matched with the fonts in the character radical block diagram corresponding to the characters in the target font image, taking the current font migration model to be trained as the target font migration model. The processing method for the font migration model provided in the first embodiment of the present application enables the target font migration model to explicitly segment the character radical block diagram for processing, so as to better perform font migration on the to-be-processed character image based on the character radical, thereby improving the font migration effect of the character image of the target font.
Second embodiment
Corresponding to the processing method for the font migration model provided in the first embodiment of the present application, a second embodiment of the present application provides a processing apparatus for the font migration model. Since the apparatus embodiment is substantially similar to the method first embodiment, it is relatively simple to describe, and reference may be made to some descriptions of the method embodiments for relevant points. The device embodiments described below are merely illustrative.
Please refer to fig. 5, which is a schematic diagram of a processing apparatus for a font migration model according to a second embodiment of the present application.
The processing device for the font migration model comprises:
a target font migration image obtaining unit 501, configured to input the sample text image and the target font image into a current font migration model to be trained, and obtain a target font migration image corresponding to the sample text image, where the current font migration model to be trained is configured to obtain a font migration image corresponding to the text image according to the text image and the target font image;
a character radical block diagram obtaining unit 502, configured to obtain a character radical block diagram corresponding to characters in the target font migration image, and obtain a character radical block diagram corresponding to characters in the target font image;
a target font migration model obtaining unit 503, configured to use the current font migration model to be trained as the target font migration model if a font in the character radical block diagram corresponding to the characters in the target font migration image matches a font in the character radical block diagram corresponding to the characters in the target font image.
Optionally, the processing apparatus for a font migration model provided in the second embodiment of the present application further includes:
a first font migration model obtaining unit, configured to adjust a parameter of the current font migration model to be trained to obtain a first font migration model if a font in the character radical cut-off map corresponding to the character in the target font migration image is not matched with a font in the character radical cut-off map corresponding to the character in the target font image;
taking the first font migration model as the current font migration model to be trained;
a first target font migration image obtaining unit, configured to input a sample text image and the target font image into the current font migration model to be trained, and obtain a first target font migration image corresponding to the sample text image;
a first character radical block diagram obtaining unit, configured to obtain a character radical block diagram corresponding to characters in the first target font migration image, and obtain a character radical block diagram corresponding to characters in the target font image;
and a second target font migration model obtaining unit, configured to, if a font in the character radical cut-off graph corresponding to the character in the first target font migration image matches a font in the character radical cut-off graph corresponding to the character in the target font image, use the current font migration model to be trained as the target font migration model.
Optionally, the processing apparatus for a font migration model provided in the second embodiment of the present application further includes: a third target font migration model obtaining unit, configured to, if a font in the character radical cut-block diagram corresponding to the character in the second target font migration image is not matched with a font in the character radical cut-block diagram corresponding to the character in the target font image, adjust a parameter of the current font migration model to be trained, obtain a second font migration model, use the second font migration model as the current font migration model to be trained, and so on until the target font migration model is obtained.
Optionally, the character radical cutout map obtaining unit 502 is specifically configured to input the target font migration image and the target font image into a radical attention model, obtain a character radical cutout map corresponding to the characters in the target font migration image, and obtain a character radical cutout map corresponding to the characters in the target font image, where the radical attention model is configured to obtain a character radical thermodynamic diagram corresponding to the characters in the font image according to the font image, and obtain a character radical cutout map corresponding to the characters in the font image according to the character radical thermodynamic diagram corresponding to the characters in the font image.
Optionally, the processing apparatus for a font migration model provided in the second embodiment of the present application further includes:
a target radical block diagram obtaining unit, configured to obtain a target radical block diagram;
a third radical thermodynamic diagram obtaining unit, configured to obtain a sample font image and a radical thermodynamic diagram corresponding to a character in the sample font image for a target radical block diagram;
a radical attention model obtaining unit, configured to obtain the radical attention model according to the target radical block diagram, the sample font image, and a character radical thermodynamic diagram corresponding to characters in the sample font image.
Optionally, the inputting the target font migration image and the target font image into the radical attention model, obtaining a character radical block diagram corresponding to characters in the target font migration image, and obtaining a character radical block diagram corresponding to characters in the target font image, includes:
scaling the target font migration image and the target font image to a specified size;
performing feature extraction on the target font migration image with the specified size and the target font image with the specified size to obtain character image features corresponding to the target font migration image and character image features corresponding to the target font image;
acquiring a character radical thermodynamic diagram corresponding to the characters in the target font migration image and a character radical thermodynamic diagram corresponding to the characters in the target font image according to the character image characteristics corresponding to the target font migration image and the character image characteristics corresponding to the target font image;
and acquiring a character radical block diagram corresponding to the characters in the target font migration image according to the character radical thermodynamic diagram corresponding to the characters in the target font migration image and the character radical thermodynamic diagram corresponding to the characters in the target font image, and acquiring a character radical block diagram corresponding to the characters in the target font image.
Optionally, the performing feature extraction on the target font migration image with the specified size and the target font image with the specified size to obtain the text image feature corresponding to the target font migration image and the text image feature corresponding to the target font image includes: and extracting character outline image characteristics of the target font migration image with the specified size and the target font image with the specified size to obtain character outline image characteristics corresponding to the target font migration image and the target font image.
Optionally, the performing feature extraction on the target font migration image with the specified size and the target font image with the specified size to obtain the text image feature corresponding to the target font migration image and the text image feature corresponding to the target font image includes: and performing character stroke image feature extraction on the target font migration image with the specified size and the target font image with the specified size to obtain character stroke image features corresponding to the target font migration image and character stroke image features corresponding to the target font image.
Optionally, the obtaining a word radical thermodynamic diagram corresponding to the word in the target font migration image and a word radical thermodynamic diagram corresponding to the word in the target font image according to the word image feature corresponding to the target font migration image and the word image feature corresponding to the target font image includes:
carrying out average pooling on the character image characteristics corresponding to the target font migration image and the character image characteristics corresponding to the target font image to obtain one-dimensional character image characteristics corresponding to the target font migration image and one-dimensional character image characteristics corresponding to the target font image;
coding the one-dimensional character image characteristics corresponding to the target font migration image and the one-dimensional character image characteristics corresponding to the target font image to obtain the context coding characteristics of the character image corresponding to the target font migration image and the context coding characteristics of the character image characteristics corresponding to the target font image;
and acquiring a character radical thermodynamic diagram corresponding to the characters in the target font migration image and a character radical thermodynamic diagram corresponding to the characters in the target font image according to the context coding characteristics of the character image corresponding to the target font migration image and the context coding characteristics of the character image characteristics corresponding to the target font image.
Optionally, the obtaining a text radical thermodynamic diagram corresponding to the text in the target font migration image and a text radical thermodynamic diagram corresponding to the text in the target font image according to the context coding feature of the text image corresponding to the target font migration image and the context coding feature of the text image feature corresponding to the target font image includes:
obtaining probability distribution information corresponding to characters in the target font migration image and probability distribution information corresponding to characters in the target font image according to the context coding features of the character image corresponding to the target font migration image and the context coding features of the character image features corresponding to the target font image;
and acquiring a character radical thermodynamic diagram corresponding to the characters in the target font migration image and a character radical thermodynamic diagram corresponding to the characters in the target font image according to the probability distribution information corresponding to the characters in the target font migration image and the probability distribution information corresponding to the characters in the target font image.
Optionally, the obtaining, according to the text radical thermodynamic diagram corresponding to the text in the target font migration image and the text radical thermodynamic diagram corresponding to the text in the target font image, a text radical block diagram corresponding to the text in the target font migration image and a text radical block diagram corresponding to the text in the target font image includes: and acquiring a character radical block diagram corresponding to the characters in the target font migration image according to the context coding characteristics of the character image corresponding to the target font migration image, the context coding characteristics of the character radical thermodynamic diagram corresponding to the characters in the target font migration image and the character image characteristics corresponding to the target font image and the character radical thermodynamic diagram corresponding to the characters in the target font image.
Optionally, the target font migration model obtaining unit 503 is specifically configured to, if a matching degree between a font in the character radical cut-block diagram corresponding to the character in the target font migration image and a font in the character radical cut-block diagram corresponding to the character in the target font image is greater than or equal to a font matching degree threshold, use the current font migration model to be trained as the target font migration model.
Optionally, if the font in the radical block diagram corresponding to the text in the target font migration image is not matched with the font in the radical block diagram corresponding to the text in the target font image, adjusting the parameter of the current font migration model to be trained to obtain a first font migration model, including: and if the matching degree of the fonts in the character radical block diagram corresponding to the characters in the target font migration image and the fonts in the character radical block diagram corresponding to the characters in the target font image is smaller than the font matching degree threshold value, adjusting the parameters of the current font migration model to be trained, and obtaining a first font migration model.
Optionally, the method further includes: and obtaining the matching degree of the fonts in the character radical block diagram corresponding to the characters in the target font migration image and the fonts in the character radical block diagram corresponding to the characters in the target font image.
Optionally, the target font migration image obtaining unit 501 is specifically configured to scale the sample text image and the target font image to a preset size; and obtaining a target font migration image corresponding to the sample text digital image according to the sample text image with the preset size and the target font image with the preset size.
The second embodiment of the present application provides a processing apparatus for a font migration model, which first inputs a sample text image and a target font image into a current font migration model to be trained, and obtains a target font migration image corresponding to the sample text image; then, acquiring a character radical block diagram corresponding to characters in the target font migration image, and acquiring a character radical block diagram corresponding to the characters in the target font image; and finally, if the fonts in the character radical block diagram corresponding to the characters in the target font migration image are matched with the fonts in the character radical block diagram corresponding to the characters in the target font image, taking the current font migration model to be trained as the target font migration model. The processing apparatus for font migration model provided in the second embodiment of the present application can enable the target font migration model to explicitly segment the character radical block diagram for processing, so as to better perform font migration on the to-be-processed character image based on the character radical, thereby improving the font migration effect of the target font character image.
Third embodiment
Corresponding to the information method provided in the first embodiment of the present application, a third embodiment of the present application provides an electronic device.
As shown in fig. 6, fig. 6 is a schematic view of an electronic device provided in an embodiment of the present application.
The electronic device includes:
a processor 601; and
a memory 602 for storing a program for a processing method for a font migration model, wherein after the device is powered on and the program for the processing method for the font migration model is executed by the processor, the following steps are performed:
a program for storing a processing method for a font migration model, the apparatus performing the following steps after being powered on and running the program for the processing method for the font migration model by the processor:
inputting a sample character image and a target font image into a current font migration model to be trained to obtain a target font migration image corresponding to the sample character image, wherein the current font migration model to be trained is used for obtaining a font migration image corresponding to the character image according to the character image and the target font image;
acquiring a character radical block diagram corresponding to characters in the target font migration image, and acquiring a character radical block diagram corresponding to the characters in the target font image;
and if the fonts in the character radical block diagram corresponding to the characters in the target font migration image are matched with the fonts in the character radical block diagram corresponding to the characters in the target font image, taking the current font migration model to be trained as a target font migration model.
It should be noted that, for the detailed description of the processing method for the font migration model executed by the electronic device according to the third embodiment of the present application, reference may be made to the related description of the first embodiment of the present application, and details are not described here again.
Fourth embodiment
In correspondence with the processing method for the font migration model provided in the first embodiment of the present application, a fourth embodiment of the present application provides a storage medium storing a program of the processing method for the font migration model, the program being executed by a processor to perform the steps of:
a program for storing a processing method for a font migration model, the apparatus performing the following steps after being powered on and running the program for the processing method for the font migration model by the processor:
inputting a sample character image and a target font image into a current font migration model to be trained to obtain a target font migration image corresponding to the sample character image, wherein the current font migration model to be trained is used for obtaining a font migration image corresponding to the character image according to the character image and the target font image;
acquiring a character radical block diagram corresponding to characters in the target font migration image, and acquiring a character radical block diagram corresponding to the characters in the target font image;
and if the fonts in the character radical block diagram corresponding to the characters in the target font migration image are matched with the fonts in the character radical block diagram corresponding to the characters in the target font image, taking the current font migration model to be trained as a target font migration model.
It should be noted that, for the detailed description of the storage medium provided in the fourth embodiment of the present application, reference may be made to the related description of the first embodiment of the present application, and details are not repeated here.
Fifth embodiment
Corresponding to the processing method for the font migration model provided in the first embodiment of the present application, a fifth embodiment of the present application provides a font migration method. Since the related contents in the fifth embodiment of the present application are similar to those in the first embodiment of the method, the description is relatively simple, and the related parts can be referred to only in the partial description of the method embodiments. The method embodiments described below are merely illustrative.
Please refer to fig. 7, which is a flowchart illustrating a font migration method according to a fifth embodiment of the present application.
In step S701, a character image to be processed and a target font image are obtained.
In the fifth embodiment of the present application, the to-be-processed text image is an image that needs font migration, and the target font image is a font image that provides font reference for the to-be-processed text image. The target font image is generally a different font image which is generated in advance and stored in a designated gallery and contains a plurality of characters with the same font style, and the characters in the target font image can be divided into all or part of predetermined radicals which form the characters.
In the fifth embodiment of the present application, after obtaining the text image to be processed and the target font image, the text image to be processed and the target font image generally need to be scaled to a preset size.
In step S702, the character image to be processed and the target font image are input to the radical segmentation unit of the target font migration model, the character radical segmentation map corresponding to the characters in the character image to be processed is output, and the character radical segmentation map corresponding to the characters in the target font image is output.
In the fifth embodiment of the present application, the target font migration model is configured to obtain a font migration image corresponding to the text image according to the text image and the target font image; and the radical cutting unit of the target font migration model is used for cutting the radicals of the characters of the character image in the target font migration model.
In the fifth embodiment of the present application, taking a process of outputting a character radical block diagram corresponding to characters in a target font image as an example, a process of inputting a to-be-processed character image and the target font image to a radical block unit of a target font migration model, outputting a character radical block diagram corresponding to characters in the to-be-processed character image, and outputting a character radical block diagram corresponding to characters in the target font image is described, where the specific process is as follows:
firstly, extracting character and image characteristics corresponding to the target font image. Specifically, the method comprises the steps of extracting character image stroke characteristics corresponding to the target font image and extracting character image contour characteristics corresponding to the target font image. The process of extracting the character image stroke features corresponding to the target font image comprises the following steps: firstly, dividing a target font image into a plurality of stroke subimages according to a preset character splitting rule, wherein the character splitting rule is a rule for indicating that a character is split into one or more strokes according to a character structure; secondly, extracting skeleton images of stroke components from the plurality of stroke sub-images, finding out a cross point in the skeleton images, calculating a two-dimensional neighborhood midpoint trunk curve of the cross point in the binary image, and extracting a cross point region; thirdly, extracting features of the stroke part, and matching the features of the stroke part to be extracted with the features of the stroke part in the standard library; and finally, combining the stroke segments according to the matching result to obtain the stroke image characteristics.
And secondly, acquiring a character radical thermodynamic diagram corresponding to the characters in the target font image according to the character image characteristics corresponding to the target font migration image. Firstly, carrying out average pooling on character image characteristics corresponding to a target font image to obtain one-dimensional character image characteristics corresponding to the target font image; then, coding the one-dimensional character image characteristics corresponding to the target font image to obtain the context coding characteristics of the character image characteristics corresponding to the target font image; and finally, acquiring a character radical thermodynamic diagram corresponding to the characters in the target font image according to the context coding characteristics of the character image characteristics corresponding to the target font image.
Thirdly, according to the character radical thermodynamic diagram corresponding to the characters in the target font image, obtaining a character radical block diagram corresponding to the characters in the target font image, wherein the specific process is as follows: and obtaining a character radical block diagram corresponding to the characters in the target font image according to the context coding characteristics of the character image characteristics corresponding to the target font image and the character radical thermodynamic diagram corresponding to the characters in the target font image.
In step S703, the character radical block diagram corresponding to the characters in the character image to be processed and the character radical block diagram corresponding to the characters in the target font image are input to the font migration unit of the target font migration model, and a target radical font migration image of the character radical corresponding to the characters in the character image to be processed is obtained through font migration.
In the fifth embodiment of the present application, a font migration unit of a target font migration model is a unit in the target font migration model, configured to obtain a target font migration image according to a character radical block diagram corresponding to characters in a character image to be processed and a character radical block diagram corresponding to characters in the target font image; the fonts in the target radical font migration image are matched with the fonts in the character radical block diagram corresponding to the characters in the target font image.
In the fifth embodiment of the present application, the process of obtaining a target radical font migration image of a radical corresponding to characters in a character image to be processed through font migration is as follows: and according to the character radicals corresponding to the characters in the character image to be processed, obtaining a character radical block diagram which is the same as the character radicals corresponding to the characters in the character image to be processed in the character radical block diagram corresponding to the characters in the target character font image, and using the character radical block diagram as a target radical font migration image.
In step S704, the target font radical migration image is assembled, and the target font migration image is obtained.
After the target font radical migration image is obtained, the target font radical migration image is assembled by taking the character structure corresponding to the characters in the character image to be processed as a reference, so that the target font radical migration image is obtained. That is, the character radical block diagram corresponding to the characters in the target font image is replaced by the character radical block diagram which is obtained in the character radical block diagram corresponding to the characters in the target font image and is the same as the character radical block diagram corresponding to the characters in the character image to be processed.
The font migration method provided by the fifth embodiment of the present application can divide the character radical block diagram for processing, so as to better perform font migration on the radical based on the character radical to-be-processed character image, thereby improving the font migration effect of the character image of the target character.
Sixth embodiment
A sixth embodiment of the present application provides a font migration apparatus corresponding to the font migration method provided in the fifth embodiment of the present application. Since the apparatus embodiment is substantially similar to the method fifth embodiment, it is relatively simple to describe, and reference may be made to some descriptions of the method embodiments for relevant points. The device embodiments described below are merely illustrative.
Please refer to fig. 8, which is a schematic diagram of a font migration apparatus according to a sixth embodiment of the present application.
The font migration device comprises:
an image obtaining unit 801, configured to obtain a text image to be processed and a target font image;
a character radical block diagram obtaining unit 802, configured to input the to-be-processed character image and the target font image to a radical block unit of a target font migration model, output a character radical block diagram corresponding to characters in the to-be-processed character image, and output a character radical block diagram corresponding to characters in the target font image;
a radical font migration image obtaining unit 803, configured to input the character radical cut-block diagram corresponding to the characters in the to-be-processed character image and the character radical cut-block diagram corresponding to the characters in the target font image into the font migration unit of the target font migration model, and obtain a target radical font migration image of the character radical corresponding to the characters in the to-be-processed character image through font migration, where a font in the target radical font migration image matches a font in the character radical cut-block diagram corresponding to the characters in the target font image;
a target font migration image obtaining unit 804, configured to assemble the target font radical migration image to obtain a target font migration image.
Optionally, the font migration apparatus provided in the sixth embodiment of the present application further includes: and the image display unit is used for displaying the target font migration image.
Optionally, the image obtaining unit 801 is specifically configured to obtain the to-be-processed text image and the target font image provided by the client.
Optionally, the method further includes: and providing the designated target font migration image corresponding to the text image to be processed to the client.
Seventh embodiment
A seventh embodiment of the present application provides an electronic device corresponding to the information method provided in the fifth embodiment of the present application.
Referring to fig. 6 again, the electronic device includes:
a processor 601; and
a memory 602 for storing a program for a font migration method, the apparatus performing the following steps after being powered on and running the program for the font migration method by the processor:
a program for storing a font migration method, the apparatus performing the following steps after being powered on and running the program of the font migration method by the processor:
acquiring a character image to be processed and a target font image;
inputting the character image to be processed and the target font image into a radical block unit of a target font migration model, outputting a character radical block diagram corresponding to characters in the character image to be processed, and outputting a character radical block diagram corresponding to characters in the target font image, wherein the target font migration model is used for obtaining a font migration image corresponding to the character image according to the character image and the target font image;
and inputting the character radical block diagram corresponding to the characters in the character image to be processed and the character radical block diagram corresponding to the characters in the target font image into a font migration unit of the target font migration model, and outputting the target font migration image corresponding to the character image to be processed.
It should be noted that, for the detailed description of the font migration method executed by the electronic device according to the seventh embodiment of the present application, reference may be made to the related description of the fifth embodiment of the present application, and details are not repeated here.
Eighth embodiment
In accordance with a font migration method provided in the fifth embodiment of the present application, an eighth embodiment of the present application provides a storage medium storing a program of the font migration method, where the program is executed by a processor to perform the following steps:
a program for storing a font migration method, the apparatus performing the following steps after being powered on and running the program of the font migration method by the processor:
acquiring a character image to be processed and a target font image;
inputting the character image to be processed and the target font image into a radical block unit of a target font migration model, outputting a character radical block diagram corresponding to characters in the character image to be processed, and outputting a character radical block diagram corresponding to characters in the target font image, wherein the target font migration model is used for obtaining a font migration image corresponding to the character image according to the character image and the target font image;
and inputting the character radical block diagram corresponding to the characters in the character image to be processed and the character radical block diagram corresponding to the characters in the target font image into a font migration unit of the target font migration model, and outputting the target font migration image corresponding to the character image to be processed.
It should be noted that, for the detailed description of the storage medium provided in the eighth embodiment of the present application, reference may be made to the related description of the fifth embodiment of the present application, and details are not described here again.
Ninth embodiment
Corresponding to the processing method for the font migration model provided in the first embodiment of the present application, a ninth embodiment of the present application provides another processing method for the font migration model. Since the related contents in the ninth embodiment of the present application are similar to those in the first embodiment of the method, the description is relatively simple, and the related parts can be referred to only in the partial description of the first embodiment of the method. The device embodiments described below are merely illustrative.
Firstly, inputting a sample text image and a target font image into a current font migration model to be trained to obtain a target font migration image corresponding to the sample text image, wherein the current font migration model to be trained is used for obtaining a font migration image corresponding to the text image according to the text image and the target font image. Then, inputting the target font migration image and the target font image into a character letter attention training model, obtaining a character letter block diagram corresponding to the characters in the target font migration image, and obtaining a character letter block diagram corresponding to the characters in the target font image, for example, the character letter block diagram corresponding to the English "hello" is the letter block diagram corresponding to each of five English letters, namely "h", "e", "l" and "o". And finally, inputting the character letter block diagram corresponding to the characters in the target font migration image and the character letter block diagram corresponding to the characters in the target font image into a font judging module or a font judging device, judging whether the fonts in the character letter block diagram corresponding to the characters in the target font migration image are matched with the fonts in the character letter block diagram corresponding to the characters in the target font image, and if the fonts in the character letter block diagram corresponding to the characters in the target font migration image are matched with the fonts in the character letter block diagram corresponding to the characters in the target font image, taking the initial font migration model as the target font migration model.
In the ninth embodiment of the present invention, the characters are generally characters having a simple structure and composed of english, latin letters, and the like, and the characters in the ninth embodiment of the present invention may also be characters including arabic numerals.
Tenth embodiment
A tenth embodiment of the present application provides another font migration method, which corresponds to the font migration method provided in the fifth embodiment of the present application. Since the related contents in the tenth embodiment of the present application are similar to those in the fifth embodiment of the method, the description is relatively simple, and the related parts can be referred to the partial description of the fifth embodiment of the method, and the method embodiments described below are only illustrative.
The font migration process corresponding to the font migration method provided in the tenth embodiment of the present application is as follows:
firstly, a character image to be processed and a target font image are obtained.
In the tenth embodiment of the present application, the to-be-processed text image is an image that needs font migration, and the target font image is a font image that provides font reference for the to-be-processed text image. The target font image is generally a different font image which is generated in advance and stored in a designated gallery and contains a plurality of characters with the same font style, and characters in the target font image can be split into all or part of preset letters forming the characters.
In the tenth embodiment of the present application, after obtaining the text image to be processed and the target font image, the text image to be processed and the target font image generally need to be scaled to a preset size.
Secondly, inputting the character image to be processed and the target font image into a letter block unit of the target font migration model, outputting a character letter block diagram corresponding to characters in the character image to be processed, and outputting a character letter block diagram corresponding to characters in the target font image.
In the tenth embodiment of the present application, the target font migration model is configured to obtain a font migration image corresponding to the text image according to the text image and the target font image; and the letter cutting unit of the target font migration model is a unit which is used for cutting the letters of the characters of the character image in the target font migration model.
In the tenth embodiment of the present application, a process of outputting a text letter block diagram corresponding to a text in a target font image is specifically taken as an example, and a process of inputting a text image to be processed and a target font image into a letter block unit of a target font migration model, outputting a text letter block diagram corresponding to a text in a text image to be processed, and outputting a text letter block diagram corresponding to a text in a target font image is described, where the specific process is as follows:
and firstly, extracting image characteristics corresponding to the target font image. Firstly, obtaining shape image characteristics corresponding to a target font image; then, matching the preset character shape image characteristics with the shape image characteristics corresponding to the target font image according to the preset character shape image characteristics; and finally, determining the letter image corresponding to the target font image according to the matching degree of the preset letter shape image characteristic and the shape image characteristic corresponding to the target font image, and extracting the letter image characteristic corresponding to the target font image.
And secondly, obtaining a character letter thermodynamic diagram corresponding to the characters in the target font image according to the character image characteristics corresponding to the target font migration image. Firstly, carrying out average pooling on character image characteristics corresponding to a target font image to obtain one-dimensional character image characteristics corresponding to the target font image; then, coding the one-dimensional character image characteristics corresponding to the target font image to obtain the context coding characteristics of the character image characteristics corresponding to the target font image; and finally, obtaining a text letter thermodynamic diagram corresponding to the text in the target font image according to the context coding characteristics of the text image characteristics corresponding to the target font image.
Thirdly, obtaining a character letter block diagram corresponding to the characters in the target font image according to the character letter thermodynamic diagram corresponding to the characters in the target font image, wherein the specific process is as follows: and obtaining a character letter block diagram corresponding to the characters in the target font image according to the context coding characteristics of the character image characteristics corresponding to the target font image and the character letter thermodynamic diagram corresponding to the characters in the target font image.
And thirdly, inputting the character letter block diagram corresponding to the characters in the character image to be processed and the character letter block diagram corresponding to the characters in the target character font image into a character font migration unit of the target character font migration model, and obtaining a target character font migration image of the character letters corresponding to the characters in the character image to be processed through character font migration.
In the tenth embodiment of the present application, a font migration unit of a target font migration model is a unit in the target font migration model, configured to obtain a target font migration image according to a text letter block diagram corresponding to a text in a text image to be processed and a text letter block diagram corresponding to a text in the target font image; the fonts in the target letter font migration image are matched with the fonts in the character letter tile map corresponding to the characters in the target letter font image.
In the tenth embodiment of the present application, the process of obtaining a target letter font migration image of a text letter corresponding to a text in a text image to be processed through font migration is as follows: and according to the character letters corresponding to the characters in the character image to be processed, obtaining a character letter block diagram which is the same as the character letters corresponding to the characters in the character image to be processed in the character letter block diagram corresponding to the characters in the target character font image, and using the character letter block diagram as a target character font migration image.
And finally, assembling the target font letter migration image to obtain the target font migration image.
After the target font letter migration image is obtained, the target font letter migration image is assembled by taking the character structure corresponding to the characters in the character image to be processed as a reference, so that the target font migration image is obtained. Namely, the character letter block diagram corresponding to the characters in the target font image is replaced by the character letter block diagram which is obtained in the character letter block diagram corresponding to the characters in the target font image and is the same as the character letters corresponding to the characters in the character image to be processed.
The font migration method provided by the tenth embodiment of the application can divide the character letter block graph for processing, so that the character image to be processed is subjected to font migration on the basis of the character letters, and the font migration effect of the character image of the target font is improved. Although the present invention has been described with reference to the preferred embodiments, it should be understood that the scope of the present invention is not limited to the embodiments described above, and that various changes and modifications may be made by one skilled in the art without departing from the spirit and scope of the present invention.
In a typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
The memory may include forms of volatile memory in a computer readable medium, Random Access Memory (RAM) and/or non-volatile memory, such as Read Only Memory (ROM) or Flash memory (Flash RAM). Memory is an example of a computer-readable medium.
1. Computer-readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), Read Only Memory (ROM), Electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), Digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information that can be accessed by a computing device. As defined herein, computer readable Media does not include non-Transitory computer readable Media (transient Media), such as modulated data signals and carrier waves.
2. As will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.

Claims (27)

1. A processing method for a font migration model is characterized by comprising the following steps:
inputting a sample character image and a target font image into a current font migration model to be trained to obtain a target font migration image corresponding to the sample character image, wherein the current font migration model to be trained is used for obtaining a font migration image corresponding to the character image according to the character image and the target font image;
acquiring a character radical block diagram corresponding to characters in the target font migration image, and acquiring a character radical block diagram corresponding to the characters in the target font image;
and if the fonts in the character radical block diagram corresponding to the characters in the target font migration image are matched with the fonts in the character radical block diagram corresponding to the characters in the target font image, taking the current font migration model to be trained as a target font migration model.
2. The processing method for the font migration model according to claim 1, further comprising:
if the font in the character radical block diagram corresponding to the characters in the target font migration image is not matched with the font in the character radical block diagram corresponding to the characters in the target font image, adjusting the parameters of the current font migration model to be trained to obtain a first font migration model;
taking the first font migration model as the current font migration model to be trained;
inputting a sample text image and the target font image into the current font migration model to be trained to obtain a first target font migration image corresponding to the sample text image;
acquiring a character radical block diagram corresponding to characters in the first target font migration image, and acquiring a character radical block diagram corresponding to characters in the target font image;
and if the font in the character radical block diagram corresponding to the characters in the first target font migration image is matched with the font in the character radical block diagram corresponding to the characters in the target font image, taking the current font migration model to be trained as a target font migration model.
3. The processing method for the font migration model according to claim 2, further comprising: if the font in the character radical block diagram corresponding to the characters in the first target font migration image is not matched with the font in the character radical block diagram corresponding to the characters in the target font image, adjusting the parameters of the current font migration model to be trained to obtain a second font migration model, taking the second font migration model as the current font migration model to be trained, and so on until the target font migration model is obtained.
4. The processing method for the font migration model according to claim 1, wherein the obtaining the radical block diagram corresponding to the characters in the target font migration image and the radical block diagram corresponding to the characters in the target font image comprises: and inputting the target font migration image and the target font image into a radical attention model, obtaining a character radical block diagram corresponding to characters in the target font migration image, and obtaining a character radical block diagram corresponding to the characters in the target font image, wherein the radical attention model is used for obtaining a character radical thermodynamic diagram corresponding to the characters in the font image according to the font image, and obtaining a character radical block diagram corresponding to the characters in the font image according to the character radical thermodynamic diagram corresponding to the characters in the font image.
5. The processing method for the font migration model according to claim 4, further comprising:
obtaining a target radical block diagram;
aiming at a target radical block diagram, obtaining a sample font image and a character radical thermodynamic diagram corresponding to characters in the sample font image;
and obtaining the radical attention model according to the target radical block diagram, the sample font image and the character radical thermodynamic diagram corresponding to the characters in the sample font image.
6. The processing method for the font migration model according to claim 4, wherein the inputting the target font migration image and the target font image into the radical attention model, obtaining the radical cut-block diagram of the characters in the target font migration image, and obtaining the radical cut-block diagram of the characters in the target font image, comprises:
scaling the target font migration image and the target font image to a specified size;
performing feature extraction on the target font migration image with the specified size and the target font image with the specified size to obtain character image features corresponding to the target font migration image and character image features corresponding to the target font image;
acquiring a character radical thermodynamic diagram corresponding to the characters in the target font migration image and a character radical thermodynamic diagram corresponding to the characters in the target font image according to the character image characteristics corresponding to the target font migration image and the character image characteristics corresponding to the target font image;
and acquiring a character radical block diagram corresponding to the characters in the target font migration image according to the character radical thermodynamic diagram corresponding to the characters in the target font migration image and the character radical thermodynamic diagram corresponding to the characters in the target font image, and acquiring a character radical block diagram corresponding to the characters in the target font image.
7. The processing method for the font migration model according to claim 6, wherein the performing feature extraction on the target font migration image with the specified size and the target font image with the specified size to obtain the text-image feature corresponding to the target font migration image and the text-image feature corresponding to the target font image includes: and extracting character outline image characteristics of the target font migration image with the specified size and the target font image with the specified size to obtain character outline image characteristics corresponding to the target font migration image and the target font image.
8. The processing method for the font migration model according to claim 6, wherein the performing feature extraction on the target font migration image with the specified size and the target font image with the specified size to obtain the text-image feature corresponding to the target font migration image and the text-image feature corresponding to the target font image includes: and performing character stroke image feature extraction on the target font migration image with the specified size and the target font image with the specified size to obtain character stroke image features corresponding to the target font migration image and character stroke image features corresponding to the target font image.
9. The processing method for the font migration model according to claim 6, wherein the obtaining a text radical thermodynamic diagram corresponding to the text in the target font migration image and a text radical thermodynamic diagram corresponding to the text in the target font image according to the text image features corresponding to the target font migration image and the text image features corresponding to the target font image comprises:
carrying out average pooling on the character image characteristics corresponding to the target font migration image and the character image characteristics corresponding to the target font image to obtain one-dimensional character image characteristics corresponding to the target font migration image and one-dimensional character image characteristics corresponding to the target font image;
coding the one-dimensional character image characteristics corresponding to the target font migration image and the one-dimensional character image characteristics corresponding to the target font image to obtain the context coding characteristics of the character image corresponding to the target font migration image and the context coding characteristics of the character image characteristics corresponding to the target font image;
and acquiring a character radical thermodynamic diagram corresponding to the characters in the target font migration image and a character radical thermodynamic diagram corresponding to the characters in the target font image according to the context coding characteristics of the character image corresponding to the target font migration image and the context coding characteristics of the character image characteristics corresponding to the target font image.
10. The processing method for the font migration model according to claim 9, wherein the obtaining the text radical thermodynamic diagram corresponding to the text in the target font migration image and the text radical thermodynamic diagram corresponding to the text in the target font image according to the context coding features of the text image corresponding to the target font migration image and the context coding features of the text image features corresponding to the target font image comprises:
obtaining probability distribution information corresponding to characters in the target font migration image and probability distribution information corresponding to characters in the target font image according to the context coding features of the character image corresponding to the target font migration image and the context coding features of the character image features corresponding to the target font image;
and acquiring a character radical thermodynamic diagram corresponding to the characters in the target font migration image and a character radical thermodynamic diagram corresponding to the characters in the target font image according to the probability distribution information corresponding to the characters in the target font migration image and the probability distribution information corresponding to the characters in the target font image.
11. The processing method for a font migration model according to claim 10, wherein the obtaining a character radical block diagram corresponding to the characters in the target font migration image and a character radical block diagram corresponding to the characters in the target font image according to the character radical thermodynamic diagrams corresponding to the characters in the target font migration image and the character radical thermodynamic diagrams corresponding to the characters in the target font image, and obtaining the character radical block diagram corresponding to the characters in the target font image comprises: and acquiring a character radical block diagram corresponding to the characters in the target font migration image according to the context coding characteristics of the character image corresponding to the target font migration image, the context coding characteristics of the character radical thermodynamic diagram corresponding to the characters in the target font migration image and the character image characteristics corresponding to the target font image and the character radical thermodynamic diagram corresponding to the characters in the target font image.
12. The processing method for the font migration model according to claim 1, wherein if a font in the radical block diagram corresponding to the text in the target font migration image matches a font in the radical block diagram corresponding to the text in the target font image, taking the current font migration model to be trained as the target font migration model includes: and if the matching degree of the fonts in the character radical block diagram corresponding to the characters in the target font migration image and the fonts in the character radical block diagram corresponding to the characters in the target font image is larger than or equal to a font matching degree threshold value, taking the current font migration model to be trained as a target font migration model.
13. The processing method for the font migration model according to claim 2, wherein if the font in the radical block diagram corresponding to the text in the target font migration image does not match the font in the radical block diagram corresponding to the text in the target font image, adjusting the parameter of the font migration model to be currently trained to obtain the first font migration model includes: and if the matching degree of the fonts in the character radical block diagram corresponding to the characters in the target font migration image and the fonts in the character radical block diagram corresponding to the characters in the target font image is smaller than the font matching degree threshold value, adjusting the parameters of the current font migration model to be trained, and obtaining a first font migration model.
14. The processing method for the font migration model according to claim 12 or 13, further comprising: and obtaining the matching degree of the fonts in the character radical block diagram corresponding to the characters in the target font migration image and the fonts in the character radical block diagram corresponding to the characters in the target font image.
15. The processing method for the font migration model according to claim 1, wherein the inputting the sample text image and the target font image into the font migration model to be trained to obtain the target font migration image corresponding to the sample text image comprises:
scaling the sample text image and the target font image to a preset size;
and obtaining a target font migration image corresponding to the sample text digital image according to the sample text image with the preset size and the target font image with the preset size.
16. A processing apparatus for a font migration model, comprising:
a target font migration image obtaining unit, configured to input a sample text image and a target font image into a current font migration model to be trained, and obtain a target font migration image corresponding to the sample text image, where the current font migration model to be trained is configured to obtain a font migration image corresponding to the text image according to the text image and the target font image;
a character radical block diagram obtaining unit, configured to obtain a character radical block diagram corresponding to characters in the target font migration image, and obtain a character radical block diagram corresponding to characters in the target font image;
and the target font migration model obtaining unit is used for taking the current font migration model to be trained as the target font migration model if the fonts in the character radical block diagram corresponding to the characters in the target font migration image are matched with the fonts in the character radical block diagram corresponding to the characters in the target font image.
17. An electronic device, comprising:
a processor; and
a memory for storing a program of a processing method for a font migration model, the apparatus performing the following steps after being powered on and running the program of the processing method for the font migration model by the processor:
inputting a sample character image and a target font image into a current font migration model to be trained to obtain a target font migration image corresponding to the sample character image, wherein the current font migration model to be trained is used for obtaining a font migration image corresponding to the character image according to the character image and the target font image;
acquiring a character radical block diagram corresponding to characters in the target font migration image, and acquiring a character radical block diagram corresponding to the characters in the target font image;
and if the fonts in the character radical block diagram corresponding to the characters in the target font migration image are matched with the fonts in the character radical block diagram corresponding to the characters in the target font image, taking the current font migration model to be trained as a target font migration model.
18. A storage medium storing a program for a font migration model processing method, the program being executed by a processor and performing the steps of:
inputting a sample character image and a target font image into a current font migration model to be trained to obtain a target font migration image corresponding to the sample character image, wherein the current font migration model to be trained is used for obtaining a font migration image corresponding to the character image according to the character image and the target font image;
acquiring a character radical block diagram corresponding to characters in the target font migration image, and acquiring a character radical block diagram corresponding to the characters in the target font image;
and if the fonts in the character radical block diagram corresponding to the characters in the target font migration image are matched with the fonts in the character radical block diagram corresponding to the characters in the target font image, taking the current font migration model to be trained as a target font migration model.
19. A method for font migration, comprising:
acquiring a character image to be processed and a target font image;
inputting the character image to be processed and the target font image into a radical block unit of a target font migration model, outputting a character radical block diagram corresponding to characters in the character image to be processed, and outputting a character radical block diagram corresponding to the characters in the target font image;
inputting a character radical block diagram corresponding to characters in the character image to be processed and a character radical block diagram corresponding to characters in the target font image into a font migration unit of the target font migration model, and obtaining a target radical font migration image of the character radical corresponding to the characters in the character image to be processed through font migration, wherein fonts in the target radical font migration image are matched with fonts in the character radical block diagram corresponding to the characters in the target font image;
and assembling the target font radical migration image to obtain a target font migration image.
20. The font migration method according to claim 19, further comprising: and displaying the target font migration image.
21. The font migration method according to claim 19, wherein said obtaining the text image to be processed and the target font image comprises: and acquiring the character image to be processed and the target font image provided by the client.
22. The processing method for font migration model according to claim 21, further comprising: and providing the designated target font migration image corresponding to the text image to be processed to the client.
23. A font migration apparatus, comprising:
the image obtaining unit is used for obtaining a character image to be processed and a target font image;
a character radical block diagram obtaining unit, configured to input the to-be-processed character image and the target font image to a radical block unit of a target font migration model, output a character radical block diagram corresponding to characters in the to-be-processed character image, and output a character radical block diagram corresponding to characters in the target font image;
a radical font migration image obtaining unit, configured to input a character radical cut-block diagram corresponding to characters in the to-be-processed character image and a character radical cut-block diagram corresponding to characters in the target font image into a font migration unit of the target font migration model, and obtain a target radical font migration image of a character radical corresponding to characters in the to-be-processed character image through font migration, where a font in the target radical font migration image matches a font in the character radical cut-block diagram corresponding to characters in the target font image;
and the target font migration image obtaining unit is used for assembling the target font radical migration images to obtain the target font migration images.
24. An electronic device, comprising:
a processor; and
a memory for storing a program of a font migration method, the apparatus performing the following steps after being powered on and executing the program of the processing method for the font migration model by the processor:
acquiring a character image to be processed and a target font image;
inputting the character image to be processed and the target font image into a radical block unit of a target font migration model, outputting a character radical block diagram corresponding to characters in the character image to be processed, and outputting a character radical block diagram corresponding to the characters in the target font image;
inputting a character radical block diagram corresponding to characters in the character image to be processed and a character radical block diagram corresponding to characters in the target font image into a font migration unit of the target font migration model, and obtaining a target radical font migration image of the character radical corresponding to the characters in the character image to be processed through font migration, wherein fonts in the target radical font migration image are matched with fonts in the character radical block diagram corresponding to the characters in the target font image;
and assembling the target font radical migration image to obtain a target font migration image.
25. A storage medium storing a program for a font migration method, the program being executed by a processor and performing the steps of:
acquiring a character image to be processed and a target font image;
inputting the character image to be processed and the target font image into a radical block unit of a target font migration model, outputting a character radical block diagram corresponding to characters in the character image to be processed, and outputting a character radical block diagram corresponding to the characters in the target font image;
inputting a character radical block diagram corresponding to characters in the character image to be processed and a character radical block diagram corresponding to characters in the target font image into a font migration unit of the target font migration model, and obtaining a target radical font migration image of the character radical corresponding to the characters in the character image to be processed through font migration, wherein fonts in the target radical font migration image are matched with fonts in the character radical block diagram corresponding to the characters in the target font image;
and assembling the target font radical migration image to obtain a target font migration image.
26. A processing method for a font migration model is characterized by comprising the following steps:
inputting a sample character image and a target font image into a current font migration model to be trained to obtain a target font migration image corresponding to the sample character image, wherein the current font migration model to be trained is used for obtaining a font migration image corresponding to the character image according to the character image and the target font image;
obtaining a character letter block diagram corresponding to the characters in the target font migration image, and obtaining a character letter block diagram corresponding to the characters in the target font image;
and if the fonts in the character letter block diagrams corresponding to the characters in the target font migration image are matched with the fonts in the character letter block diagrams corresponding to the characters in the target font image, taking the current font migration model to be trained as a target font migration model.
27. A method for font migration, comprising:
acquiring a character image to be processed and a target font image;
inputting the character image to be processed and the target font image into a radical block unit of a target font migration model, outputting a character letter block diagram corresponding to characters in the character image to be processed, and outputting a character letter block diagram corresponding to characters in the target font image;
inputting a character letter block diagram corresponding to characters in the character image to be processed and a character letter block diagram corresponding to characters in the target font image into a font migration unit of the target font migration model, and obtaining a target radical font migration image of the character letters corresponding to the characters in the character image to be processed through font migration, wherein fonts in the target radical font migration image are matched with fonts in the character letter block diagram corresponding to the characters in the target font image;
and assembling the target font radical migration image to obtain a target font migration image.
CN202010381723.6A 2020-05-08 2020-05-08 Processing method and device for font migration model and electronic equipment Pending CN113627124A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010381723.6A CN113627124A (en) 2020-05-08 2020-05-08 Processing method and device for font migration model and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010381723.6A CN113627124A (en) 2020-05-08 2020-05-08 Processing method and device for font migration model and electronic equipment

Publications (1)

Publication Number Publication Date
CN113627124A true CN113627124A (en) 2021-11-09

Family

ID=78377337

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010381723.6A Pending CN113627124A (en) 2020-05-08 2020-05-08 Processing method and device for font migration model and electronic equipment

Country Status (1)

Country Link
CN (1) CN113627124A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114820867A (en) * 2022-04-22 2022-07-29 北京百度网讯科技有限公司 Font generation method, font generation model training method and device

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114820867A (en) * 2022-04-22 2022-07-29 北京百度网讯科技有限公司 Font generation method, font generation model training method and device
CN114820867B (en) * 2022-04-22 2022-12-13 北京百度网讯科技有限公司 Font generation method, font generation model training method and device

Similar Documents

Publication Publication Date Title
CN111652217B (en) Text detection method and device, electronic equipment and computer storage medium
CN110738207B (en) Character detection method for fusing character area edge information in character image
CN110348294B (en) Method and device for positioning chart in PDF document and computer equipment
CN108229303B (en) Detection recognition and training method, device, equipment and medium for detection recognition network
CN113313083B (en) Text detection method and device
KR20160147374A (en) Apparatus for extracting object of interest in image using image matting based on global contrast and method using the same
CN112597918B (en) Text detection method and device, electronic equipment and storage medium
CN108182457B (en) Method and apparatus for generating information
CN111612004A (en) Image clipping method and device based on semantic content
CN114596566A (en) Text recognition method and related device
CN112465020A (en) Training data set generation method and device, electronic equipment and storage medium
CN110738238A (en) certificate information classification positioning method and device
CN116805368A (en) Feature separation and recombination-based small sample image semantic segmentation method
CN110619334A (en) Portrait segmentation method based on deep learning, architecture and related device
CN106611148B (en) Image-based offline formula identification method and device
CN113657370B (en) Character recognition method and related equipment thereof
EP4075381B1 (en) Image processing method and system
CN113627124A (en) Processing method and device for font migration model and electronic equipment
CN110826488A (en) Image identification method and device for electronic document and storage equipment
CN114998897B (en) Method for generating sample image and training method of character recognition model
CN114399782B (en) Text image processing method, apparatus, device, storage medium, and program product
CN108021918B (en) Character recognition method and device
CN113850239B (en) Multi-document detection method and device, electronic equipment and storage medium
US11776168B2 (en) Extracting textures from text based images
CN115294578A (en) Text information extraction method, device, equipment and medium based on artificial intelligence

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination