Font style migration network training method and device, equipment and storage medium

CN118613844APending Publication Date: 2024-09-06BOE TECHNOLOGY GROUP CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202380000008.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-01-04
Publication Date
2024-09-06

AI Technical Summary

Technical Problem

The existing technology makes it difficult to directly adjust the font style of text marks that are difficult to determine, such as handwritten characters on a handwriting screen and characters in images, and it is difficult to adapt to the effects of different display scenes in the display.

Method used

The font style transfer network using a generative adversarial network structure obtains a set of preset character image samples, including original character images and their sampling information, and trains the generative model and the discriminant model to achieve font style transfer.

Benefits of technology

It has realized the font style migration of character images, which can improve the display effect in different scenarios and flexibly adapt to multiple font styles without specifying the migration target style.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118613844A
    Figure CN118613844A
Patent Text Reader

Abstract

The invention discloses a font style migration network training method and device, equipment and a storage medium. The method comprises the steps of obtaining a preset font style migration network, wherein the preset font style migration network is a generative adversarial network; a preset character image sample set is obtained, the preset character image sample set comprises a plurality of first character image samples, and the first character image samples comprise first original character images, sampling information of the first original character images and first target character images; the first original character image and the sampling information of the first original character image are sample features, the first target character image is a sample label, and the first original character image and the first target character image in the same character image sample represent the same character; and training a preset font style migration network by using the preset character image sample set to obtain a target font style migration network.
Need to check novelty before this filing date? Find Prior Art

Description

Training method, device, equipment and storage medium for font style transfer network Technical Field

[0001] The present invention relates to the field of machine learning technology, and in particular to a training method, apparatus, device and storage medium for a font style transfer network. Background Art

[0002] With the popularization of computer technology, there are many business scenarios that require displaying text, such as web front-end design, advertising packaging, and handwriting screens.

[0003] In actual presentations, text often has a font style. For example, Songti, Heiti, and Handwritten. Different font styles can adapt to different presentation scenarios and improve the presentation effect. You can usually adjust the font style of the text to improve the presentation effect.

[0004] The existing method can only set the font style based on the text logo, find the font image representing the text in the font library of the corresponding style, and display it.

[0005] However, for character images whose text identifiers are difficult to directly determine, such as handwritten characters on a handwriting screen or characters in an image, it is often difficult to adjust the font style.

[0006] Summary of the Invention

[0007] The present invention provides a training method, apparatus, device and storage medium for a font style transfer network to address deficiencies in related technologies.

[0008] According to a first aspect of an embodiment of the present invention, a method for training a font style transfer network is provided, comprising:

[0009] Obtaining a preset font style transfer network, wherein the preset font style transfer network is a generative adversarial network;

[0010] Obtaining a preset character image sample set, wherein the preset character image sample set includes a plurality of first character image samples, the first character image sample including a first original character image, sampling information of the first original character image, and a first target character image, the first original character image and the sampling information of the first original character image being sample features, the first target character image being a sample label, and the first original character image and the first target character image in the same character image sample representing the same character;

[0011] The preset character image sample set is used to train the preset font style transfer network to obtain a target font style transfer network.

[0012] Optionally, the preset character image sample set includes a plurality of first target character images representing the same character, and different first target character images representing the same character correspond to different first original character images.

[0013] Optionally, the preset font style transfer network includes a preset generation model and a preset discrimination model;

[0014] The preset generation model is used to generate a migration result image based on an original character image and sampling information of the original character image, and the preset discrimination model is used to predict the probability that the migration result image is a target character image.

[0015] Optionally, the sampling information includes: character sampling point position information and / or character trajectory position information.

[0016] Optionally, when the sampling information includes character sampling point position information, the sampling information also includes character sampling point sequence information; and / or

[0017] In the case where the sampling information includes character trajectory position information, the sampling information also includes character trajectory order information.

[0018] Optionally, the sampling information is obtained by:

[0019] Sampling is performed on the writing trajectory of the first original character image to obtain sampling information.

[0020] Optionally, sampling the writing trajectory of the first original character image to obtain sampling information includes:

[0021] The writing trajectory of the first original character image on the touch screen is sampled to obtain a trajectory with a time sequence relationship and determine it as sampling information.

[0022] Optionally, the sampling information is obtained by:

[0023] Sampling is performed on the first original character image to obtain sampling information.

[0024] Optionally, the preset generation model includes an image encoder, a sampling information encoder and a decoder;

[0025] The preset generation model is used to: use the image encoder to extract image features from the original character image, use the sampling information encoder to extract sampling information features from the sampling information of the original character image, perform channel superposition on the extracted image features and sampling information features to obtain channel superposition results, and use the decoder to generate a migration result image based on the obtained channel superposition results.

[0026] Optionally, obtaining a preset font style transfer network includes:

[0027] Obtaining a pre-trained initial font style transfer network, where the initial font style transfer network is a generative adversarial network, including an initial generative model and an initial discriminative model;

[0028] The initial generation model is used to generate a second migration initial image for the second original character image, and the initial discrimination model is used to predict the probability that the second migration initial image is a target character image;

[0029] The initial font style transfer network is converted into a preset font style transfer network, including: adding a sampling information encoder for encoding sampling information of the original character image to an initial generation model in the initial font style transfer network, and cascading the output of the sampling information encoder to the input of a decoder in the initial generation model to obtain a preset generation model, and determining the initial discriminant model as the preset discriminant model.

[0030] Optionally, the obtaining of the pre-trained initial font style transfer network includes: training the initial font style transfer network to obtain the pre-trained initial font style transfer network;

[0031] The step of training the initial font style transfer network includes:

[0032] Acquire an initial character image sample set, the initial character image sample set including a plurality of second character image samples, the second character image samples including the second original character image and the second target character image, the second original character image being a sample feature, the second target character image being a sample label, and the second original character image and the second target character image in the same second character image sample representing the same character;

[0033] The initial font style transfer network is trained using the initial character image sample set.

[0034] Optionally, the second original character image includes: a handwritten character image;

[0035] The second target character image includes a character image in a printed font style.

[0036] Optionally, the different first target character images representing the same character have different font styles;

[0037] The preset generation model in the target font style transfer network has the following functions: for different character image inputs representing the same character, outputting transfer result character images with different font styles.

[0038] Optionally, the method for obtaining character image samples from the preset character image sample set includes:

[0039] Determine different character images representing the same character and having different font styles as first target character images respectively;

[0040] Sample features are respectively acquired according to the determined first target character image to obtain first character image samples.

[0041] Optionally, the acquiring of sample features respectively according to the determined first target character image includes at least one of the following:

[0042] For any determined first target character image, perform image enhancement processing to obtain at least one first original character image, and determine sampling information for the obtained first original character image;

[0043] For any determined first target character image, determining at least one character image having an image similarity with the first target character image higher than a preset similarity as a first original character image, and determining sampling information for the determined first original character image;

[0044] For any determined first target character image, at least one character image of the copied writing is obtained and determined as a first original character image, and sampling information is determined for the determined first original character image.

[0045] Optionally, the different first target character images representing the same character have different handwriting styles;

[0046] The preset generation model in the target font style transfer network has the following functions: for different character image inputs representing the same character, outputting transfer result character images with different handwriting styles.

[0047] Optionally, the method for obtaining character image samples from the preset character image sample set includes:

[0048] Determine different character images representing the same character and having different handwriting styles as first target character images respectively;

[0049] Sample features are respectively acquired according to the determined first target character image to obtain first character image samples.

[0050] Optionally, the acquiring of sample features respectively according to the determined first target character image includes at least one of the following:

[0051] For any determined first target character image, perform image enhancement processing to obtain at least one first original character image, and determine sampling information for the obtained first original character image;

[0052] For any determined first target character image, determining at least one character image having an image similarity with the first target character image higher than a preset similarity as a first original character image, and determining sampling information for the determined first original character image;

[0053] For any determined first target character image, obtaining at least one character image of the copied writing, determining it as a first original character image, and determining sampling information for the determined first original character image;

[0054] For any determined first target character image, at least one character image obtained by handwriting the character represented by the first target character image based on the same handwriting style is determined as a first original character image, and sampling information is determined for the determined first original character image.

[0055] Optionally, the method for obtaining character image samples from the preset character image sample set includes:

[0056] Obtain different character images of the same character written by different people, and different people have different handwriting styles;

[0057] The number of character images obtained by the same person for the same character using the same handwriting style is greater than or equal to 2;

[0058] Among the character images handwritten by the same person, any character image is determined as a first target character image, and the other character images are determined as first original character images. Sampling information is determined for the determined first original character image to obtain a character image sample.

[0059] According to a second aspect of an embodiment of the present invention, a training device for a font style transfer network is provided, comprising:

[0060] A network acquisition unit, configured to acquire a preset font style transfer network, wherein the preset font style transfer network is a generative adversarial network;

[0061] a sample acquisition unit, configured to acquire a preset character image sample set, wherein the preset character image sample set includes a plurality of first character image samples, the first character image sample includes a first original character image, sampling information of the first original character image, and a first target character image, the first original character image and the sampling information of the first original character image are sample features, the first target character image is a sample label, and the first original character image and the first target character image in the same character image sample represent the same character;

[0062] A training unit is used to train the preset font style transfer network using the preset character image sample set to obtain a target font style transfer network.

[0063] Optionally, the preset character image sample set includes a plurality of first target character images representing the same character, and different first target character images representing the same character correspond to different first original character images.

[0064] Optionally, the preset font style transfer network includes a preset generation model and a preset discrimination model;

[0065] The preset generation model is used to generate a migration result image based on an original character image and sampling information of the original character image, and the preset discrimination model is used to predict the probability that the migration result image is a target character image.

[0066] Optionally, the sampling information includes: character sampling point position information and / or character trajectory position information.

[0067] Optionally, when the sampling information includes character sampling point position information, the sampling information also includes character sampling point sequence information; and / or

[0068] In the case where the sampling information includes character trajectory position information, the sampling information also includes character trajectory order information.

[0069] Optionally, the sampling information is obtained by:

[0070] Sampling is performed on the writing trajectory of the first original character image to obtain sampling information.

[0071] Optionally, sampling the writing trajectory of the first original character image to obtain sampling information includes:

[0072] The writing trajectory of the first original character image on the touch screen is sampled to obtain a trajectory with a time sequence relationship and determine it as sampling information.

[0073] Optionally, the sampling information is obtained by:

[0074] Sampling is performed on the first original character image to obtain sampling information.

[0075] Optionally, the preset generation model includes an image encoder, a sampling information encoder and a decoder;

[0076] The preset generation model is used to: use the image encoder to extract image features from the original character image, use the sampling information encoder to extract sampling information features from the sampling information of the original character image, perform channel superposition on the extracted image features and sampling information features to obtain channel superposition results, and use the decoder to generate a migration result image based on the obtained channel superposition results.

[0077] Optionally, the network acquisition unit is configured to:

[0078] Obtaining a pre-trained initial font style transfer network, where the initial font style transfer network is a generative adversarial network, including an initial generative model and an initial discriminative model;

[0079] The initial generation model is used to generate a second migration initial image for the second original character image, and the initial discrimination model is used to predict the probability that the second migration initial image is a target character image;

[0080] The initial font style transfer network is converted into a preset font style transfer network, including: adding a sampling information encoder for encoding sampling information of the original character image to an initial generation model in the initial font style transfer network, and cascading the output of the sampling information encoder to the input of a decoder in the initial generation model to obtain a preset generation model, and determining the initial discriminant model as the preset discriminant model.

[0081] Optionally, the network acquisition unit is used to: train the initial font style transfer network to obtain the pre-trained initial font style transfer network;

[0082] Wherein, the network acquisition unit is used to:

[0083] Acquire an initial character image sample set, the initial character image sample set including a plurality of second character image samples, the second character image samples including the second original character image and the second target character image, the second original character image being a sample feature, the second target character image being a sample label, and the second original character image and the second target character image in the same second character image sample representing the same character;

[0084] The initial font style transfer network is trained using the initial character image sample set.

[0085] Optionally, the second original character image includes: a handwritten character image;

[0086] The second target character image includes a character image in a printed font style.

[0087] Optionally, the different first target character images representing the same character have different font styles;

[0088] The preset generation model in the target font style transfer network has the following functions: for different character image inputs representing the same character, outputting transfer result character images with different font styles.

[0089] Optionally, the method for obtaining character image samples from the preset character image sample set includes:

[0090] Determine different character images representing the same character and having different font styles as first target character images respectively;

[0091] Sample features are respectively acquired according to the determined first target character image to obtain first character image samples.

[0092] Optionally, the acquiring of sample features respectively according to the determined first target character image includes at least one of the following:

[0093] For any determined first target character image, perform image enhancement processing to obtain at least one first original character image, and determine sampling information for the obtained first original character image;

[0094] For any determined first target character image, determining at least one character image having an image similarity with the first target character image higher than a preset similarity as a first original character image, and determining sampling information for the determined first original character image;

[0095] For any determined first target character image, at least one character image of the copied writing is obtained and determined as a first original character image, and sampling information is determined for the determined first original character image.

[0096] Optionally, the different first target character images representing the same character have different handwriting styles;

[0097] The preset generation model in the target font style transfer network has the following functions: for different character image inputs representing the same character, outputting transfer result character images with different handwriting styles.

[0098] Optionally, the method for obtaining character image samples from the preset character image sample set includes:

[0099] Determine different character images representing the same character and having different handwriting styles as first target character images respectively;

[0100] Sample features are respectively acquired according to the determined first target character image to obtain first character image samples.

[0101] Optionally, the acquiring of sample features respectively according to the determined first target character image includes at least one of the following:

[0102] For any determined first target character image, perform image enhancement processing to obtain at least one first original character image, and determine sampling information for the obtained first original character image;

[0103] For any determined first target character image, determining at least one character image having an image similarity with the first target character image higher than a preset similarity as a first original character image, and determining sampling information for the determined first original character image;

[0104] For any determined first target character image, obtaining at least one character image of the copied writing, determining it as a first original character image, and determining sampling information for the determined first original character image;

[0105] For any determined first target character image, at least one character image obtained by handwriting the character represented by the first target character image based on the same handwriting style is determined as a first original character image, and sampling information is determined for the determined first original character image.

[0106] Optionally, the method for obtaining character image samples from the preset character image sample set includes:

[0107] Obtain different character images of the same character written by different people, and different people have different handwriting styles;

[0108] The number of character images obtained by the same person for the same character using the same handwriting style is greater than or equal to 2;

[0109] Among the character images handwritten by the same person, any character image is determined as a first target character image, and the other character images are determined as first original character images. Sampling information is determined for the determined first original character image to obtain a character image sample.

[0110] According to the above embodiments, by using character image samples to train a preset font style transfer network, the trained preset font style transfer network can be used to perform font style transfer on character images, thereby facilitating font style transfer of character images.

[0111] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the invention. BRIEF DESCRIPTION OF THE DRAWINGS

[0112] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.

[0113] FIG1 is a schematic flow chart of a method for training a font style transfer network according to an embodiment of the present invention;

[0114] FIG2 is a schematic diagram of the structure of a preset font style transfer network according to an embodiment of the present invention;

[0115] FIG3 is a schematic flow chart of a font style transfer method according to an embodiment of the present invention;

[0116] FIG4 is a schematic diagram showing the principle of font style migration according to an embodiment of the present invention;

[0117] FIG5 is a schematic structural diagram of a training device for a font style transfer network according to an embodiment of the present invention;

[0118] FIG6 is a schematic structural diagram of a training device for a font style transfer network according to an embodiment of the present invention;

[0119] FIG7 is a schematic diagram of the hardware structure of a computer device configured with the method according to an embodiment of the present invention. DETAILED DESCRIPTION

[0120] Exemplary embodiments will be described in detail herein, examples of which are illustrated in the accompanying drawings. In the following description, when referring to the drawings, like numbers in different figures represent like or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments are not intended to represent all possible embodiments consistent with the present invention. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present invention, as detailed in the appended claims.

[0121] With the popularization of computer technology, there are many business scenarios that require displaying text, such as web front-end design, advertising packaging, and handwriting screens.

[0122] In actual presentations, text often has a font style. For example, Songti, Heiti, and Handwritten. Different font styles can adapt to different presentation scenarios and improve the presentation effect. You can usually adjust the font style of the text to improve the presentation effect.

[0123] The existing method can only set the font style based on the text identifier, search for the font image representing the text in the font library of the corresponding style, and display it.

[0124] However, for character images whose text identifiers are difficult to directly determine, such as handwritten characters on a handwriting screen, characters in an image, etc., it is often difficult to adjust the font style.

[0125] An embodiment of the present invention discloses a training method for a font style transfer network.

[0126] In this method, a generative adversarial network can be used as the structure of the font style transfer network, and then the network can be trained through adversarial learning. The font style transfer network can include a generative model and a discriminative model.

[0127] Furthermore, character image samples can be obtained for training the font style transfer network.

[0128] For the sake of convenience of explanation, in this specification, optionally, the character itself may not have a font style and can be used to represent a conceptual character. And the character image can have a font style. And the characters in this specification are not limited to languages or types, and may specifically include Chinese characters, numerical characters, English characters, etc.

[0129] For example, for the character "专" without a font style, there can be multiple character images, namely the character "专" in Song typeface, the character "专" in regular script, the character "专" in boldface, and the character "专" in handwriting. For the character "a" without a font style, there can be multiple character images, namely the character "a" in fancy typeface, the character "a" in boldface, and the character "a" in handwriting.

[0130] An embodiment of the present invention provides a training method for a font style transfer network. Among them, multi-label character image samples can be obtained. Specifically, for the same character image, corresponding multiple sample labels can be set, and different sample labels can specifically include different font styles. [[ID=​​​​​​​​

[0134] Furthermore, for the font style transfer network, it is necessary to set a feature input of the transfer target font style to specify the font style to be transferred to, so that different font styles can be learned separately.

[0135] For example, when training a font style transfer network, you can input features that indicate the "target font style" is Songti, and further train it using a set of samples labeled Songti. Then, you can input features that indicate the "target font style" is Heiti, and further train it using a set of samples labeled Heiti. And so on.

[0136] The trained font style transfer network can be used to transfer the input character image to the "specified transfer target font style" when the transfer target font style is specified.

[0137] For ease of understanding, in an optional specific example, the trained font style transfer network can be deployed on a handwriting screen device, so that when a certain "migration target font style" is specified, such as Kaiti, the character image of the user's handwriting input can be migrated to the "migration target font style", thereby improving the display effect.

[0138] For example, characters written casually by users or difficult for viewers to recognize can be migrated to regular script style, making it easier for viewers to view and improving the display effect.

[0139] Therefore, the trained font style transfer network can facilitate font style transfer for character images.

[0140] Furthermore, in order to improve the flexibility of font style transfer, there is no need to specify the target font style to be transferred, so that the trained font style transfer network can learn multiple different font styles of the same character. An embodiment of the present invention also provides another training method for the font style transfer network.

[0141] In this method, the trained font style transfer network can be enabled to transfer different character images representing the same character to different font styles respectively, without specifying the transfer target font style, thereby enabling more flexible font style transfer.

[0142] For example, without specifying the target font style for migration, the trained font style migration network can migrate the character image representing the "zhuan" character and which is a user's copy of Song font to Song font, and further can migrate the character image representing the "zhuan" character and which is a user's copy of Kai font to Kai font.

[0143] Of course, this specification does not limit the specific font styles that can be transferred by the font style transfer network. Optionally, it can include Songti, Heiti, Kaiti, etc., and can also include personal handwriting styles of different users.

[0144] For example, different users can have different personal handwriting styles for the same font. These styles can include shorter horizontal strokes and longer vertical strokes, tilting both horizontal and vertical strokes at a certain angle, and including more connected strokes. The trained font style transfer network can learn from multiple users' personal handwriting styles and can then transfer different character images representing the same character to different personal handwriting styles.

[0145] Correspondingly, the font style transfer network trained by this method is not limited to a single font style for the same character, but can present multiple font styles, thereby improving the display effect and flexibility.

[0146] For example, the trained font style transfer network can be deployed on a handwriting screen device, so that the handwritten character images of different users can be migrated to different font styles, specifically different personal handwriting styles, which makes it easier to distinguish the handwritten character images of different users, improves the display effect and flexibility, and does not require specifying the migration target font style, nor does it require repeated and redundant specification of different migration target font styles when different font styles need to be displayed.

[0147] In a specific example, the character image written by user a can be migrated to the personal handwriting style of "short horizontal and long vertical", and the character image written by user b can be migrated to the personal handwriting style of "long horizontal and short vertical". This process does not require specifying the migration target font style, so that different font styles can be flexibly displayed, which makes it easy to distinguish the handwriting traces of different users and improve the display effect.

[0148] Correspondingly, optionally, when acquiring character image samples, for the same character, different character image samples may be acquired, each including a different target character image representing the same character, and each including a different original character image.

[0149] The original character image can be determined as the sample feature, and the target character image can be determined as the sample label.

[0150] Furthermore, the same original character image may correspond to only one target character image, rather than to multiple target character images of different font styles.

[0151] In other words, different target character images representing the same character may correspond to different original character images and may not correspond to the same original character image.

[0152] Therefore, optionally, for different target character images representing the same character, there may be no intersection between the corresponding different original character image sets.

[0153] Optionally, the font style transfer network can be trained by using the acquired character image samples to learn the mapping relationship between different sets of original character images and different target character images representing the same character for the same character, thereby learning different font styles for the same character. This allows the trained font style transfer network to migrate different character images representing the same character to different font styles respectively, without specifying the migration target font style, thereby allowing for more flexible font style transfer.

[0154] Optionally, different target character images may have different font styles, specifically, different personal handwriting styles.

[0155] Therefore, the training method of the font style transfer network provided in the embodiment of the present invention can train a font style transfer network with a generative adversarial network structure by utilizing character image samples of different original character images corresponding to different target character images, thereby learning different font styles of the same character (that is, different font styles included in different target character images), so that the trained font style transfer network can migrate to different font styles for different character images representing the same character, without specifying the migration target font style, thereby enabling more flexible font style transfer.

[0156] The following is a detailed explanation of a font style transfer network training method provided by an embodiment of the present invention.

[0157] As shown in FIG1 , FIG1 is a flow chart of a method for training a font style transfer network according to an embodiment of the present invention.

[0158] The embodiment of the present invention does not limit the execution subject of the method process. Optionally, the execution subject can be any computing device. For example, a server for font style migration, or a terminal that needs to perform font style migration.

[0159] The method may include the following steps.

[0160] S101: Obtain a preset font style transfer network.

[0161] Optionally, the preset font style transfer network may be a generative adversarial network.

[0162] S102: Obtain a preset character image sample set.

[0163] Optionally, the preset character image sample set may include multiple first character image samples, the first character image sample may include the first original character image, sampling information of the first original character image and the first target character image, the first original character image and the sampling information of the first original character image are sample features, the first target character image is the sample label, and the first original character image and the first target character image in the same character image sample represent the same character.

[0164] Optionally, the preset character image sample set includes a plurality of first target character images representing the same character, and different first target character images representing the same character correspond to different first original character images.

[0165] It should be noted that, to facilitate the distinction between original character images in different sample sets, the character image samples in the preset character image sample set are referred to as first character image samples. The first original character image belongs to the original character image. To facilitate the distinction between original character images in different sample sets, the original character image whose sample features are included in the preset character image sample set is referred to as the first original character image. The first target character image belongs to the target character image. To facilitate the distinction between target character images in different sample sets, the target character image whose sample features are included in the preset character image sample set is referred to as the first target character image.

[0166] S103: Using a preset character image sample set to train a preset font style transfer network to obtain a target font style transfer network.

[0167] Optionally, the preset font style transfer network may include a preset generation model and a preset discrimination model.

[0168] Optionally, the preset generation model may be used to generate a migration result image for the original character image and sampling information of the original character image, and the preset discrimination model may be used to predict the probability that the migration result image is the target character image.

[0169] Optionally, a preset font style transfer network can be used to input the target character image and the transfer result image into a preset discriminant model; the preset discriminant model can be used to predict the probability that the input image is the target character image.

[0170] The execution order of S101 and S102 is not limited by the present method flow, and can be executed in parallel or in series.

[0171] The above method process, by using character image samples to train a preset font style transfer network, can enable the trained preset font style transfer network to be used for font style transfer of character images, thereby facilitating font style transfer of character images.

[0172] Moreover, by using character image samples of different original character images corresponding to different target character images, a preset font style transfer network of a generative adversarial network structure is trained, so that different font styles of the same character (that is, different font styles included in different target character images) can be learned, so that the trained target font style transfer network can migrate to different font styles for different character images representing the same character, without specifying the migration target font style, thereby making font style transfer more flexible.

[0173] In addition, it should be noted that since the preset font style transfer network trained in the process of this method needs to learn different font styles of the same character, in order to improve the convergence speed and reduce the convergence difficulty, the sampling information of the original character image can be added as the new feature input of the preset font style transfer network, thereby increasing the constraints and reducing the learning search range of the network, which is beneficial to the convergence of the network.

[0174] The following is a detailed explanation of each step.

[0175] 1. S101: Obtaining a preset font style transfer network.

[0176] Optionally, the preset font style transfer network may be a generative adversarial network, including a preset generative model and a preset discriminative model.

[0177] 1. About the structure of the preset font style transfer network.

[0178] This method does not limit the specific structure of the preset font style transfer network.

[0179] Optionally, the preset font style transfer network may include a preset generation model and a preset discrimination model.

[0180] Optionally, a preset generation model can be used to generate a migration result image for the original character image and sampling information of the original character image, and a preset font style migration network can be used to input the target character image and the migration result image into a preset discriminant model; the preset discriminant model can be used to predict the probability that the input image is the target character image.

[0181] Optionally, a preset discrimination model can be used to discriminate between the transfer result image and the target character image. Optionally, the preset discrimination model can discriminate between the input transfer result image and the target character image.

[0182] Optionally, the preset generation model may include an encoder and a decoder. The encoder may be used to extract features from an input original character image and sampling information of the original character image, while the decoder may be used to generate and output a font style transfer result image of a conversion prediction based on the features extracted by the encoder.

[0183] This embodiment does not limit the specific feature extraction method of the encoder. Optionally, features can be extracted comprehensively based on the input original character image and the sampling information of the original character image. Specifically, the original character image and the sampling information of the original character image can be fused and then features can be extracted. Alternatively, features can be extracted separately for the input original character image and the sampling information of the original character image, and then the extracted features can be combined. Optionally, the encoder can also be used to extract style features based on font style.

[0184] This embodiment does not limit the specific way in which the decoder generates images. Alternatively, the image can be generated based on features extracted by the encoder.

[0185] Optionally, the preset generation model may include an image encoder, a sampling information encoder, and a decoder.

[0186] Among them, the preset generation model can be used to: use the image encoder to extract image features from the original character image; use the sampling information encoder to extract sampling information features from the sampling information of the original character image; perform channel superposition (concat, that is, superimpose the image features and sampling information features as different channel features, for example, perform channel superposition on the image features of the n channel and the sampling information features of the m channel to obtain the channel superposition features of the (n+m) channel) on the extracted image features and sampling information features to obtain the channel superposition results; use the decoder to generate the migration result image based on the obtained channel superposition results.

[0187] Optionally, the extracted image features and sampling information features may be subjected to comprehensive processing, specifically, they may be subjected to addition, merging, convolution processing, etc. This embodiment does not limit the specific manner of comprehensive processing.

[0188] In this embodiment, it should be emphasized that the setting of the sampling information encoder is a new encoder added to the generation model in this embodiment, so that the features of the sampling information can be extracted more conveniently and accurately, thereby improving the feature extraction effect of the sampling information.

[0189] For a detailed explanation of the sampling information, please see below.

[0190] Optionally, the preset generation model may also include an image encoder, a sampling information encoder, a font style encoder, and a decoder.

[0191] For ease of understanding, as shown in FIG2 , FIG2 is a schematic structural diagram of a preset font style transfer network according to an embodiment of the present invention.

[0192] The preset font style transfer network may include a preset generative model and a preset discriminative model. The preset generative model may include an image encoder, a sampling information encoder, and a decoder.

[0193] The original character image and the sampling information of the original character image can be input into the preset generation model in the preset font style transfer network, so that the two feature inputs can be distinguished. The character image is input into the image encoder, and the sampling information of the character image is input into the sampling information encoder, and then the image features output by the image encoder and the sampling information features output by the sampling information encoder can be obtained.

[0194] The image features and sampling information features can be combined, stacked or channel-overlaid, or processed in other comprehensive ways, and further input into the decoder to obtain the migration result image output by the decoder.

[0195] The target character image corresponding to the original character image can be input into a preset discrimination model together with the migration result image for discrimination.

[0196] Optionally, the original character image may also be input into a preset discriminant model, and the preset discriminant model predicts the probability that the input image (transferred result image) is the target character image based on the original character image.

[0197] The discrimination results can be used to train a preset font style transfer network until a preset training stop condition is met.

[0198] It should be noted that the network structure shown in FIG2 is only for illustrative purposes and does not limit the scope of disclosure of this specification.

[0199] In addition, this method does not limit the training method and loss function of the preset font style transfer network.

[0200] Optionally, the loss function may include at least one of the following.

[0201] 1) Category loss is essentially a binary cross-entropy loss, which constrains the font style of the generated transfer result image to be the same as the font style of the target character image.

[0202] 2) Const loss is essentially the MSE loss, which calculates the MSE loss between the target character image and the transferred result image. It calculates the error between the features of the target character image and the transferred result image after passing through the encoder.

[0203] That is, if two characters are similar, then the features of the target character image and the generated migration result image after passing through the encoder should also be similar.

[0204] Const loss constrains that the target character image and the generated migration result image are the same word.

[0205] 3) L1 loss is to directly calculate the mean absolute error loss of the generated migration result image and the target character image.

[0206] 4) True / Fake loss. Specifically, it can be calculated by calculating the error between the probability of the preset discriminant model output and the actual result of whether the input image is the target character image.

[0207] Optionally, the true_loss in True / fake loss may be a cross entropy loss calculated based on the probability predicted by a preset discriminant model for the input target character image.

[0208] fake_loss can be the cross entropy loss calculated by the preset discriminant model based on the probability predicted by the input migration result image.

[0209] The loss function can be used to constrain the output of the model as much as possible, reducing the probability of the model learning to obtain blurry fonts.

[0210] 2. How to obtain the preset font style transfer network.

[0211] This method does not limit the method for obtaining the preset font style transfer network.

[0212] Alternatively, a generative adversarial network can be directly constructed and determined as a preset font style transfer network, wherein the parameters can be randomly set.

[0213] Optionally, a pre-trained font style transfer network may be obtained first, specifically a font style transfer network trained using character image samples in any form, thereby obtaining a font style transfer network with a certain font style learning capability.

[0214] Furthermore, based on the structure and parameters of the obtained font style transfer network, the structure can be modified to obtain a preset font style transfer network, and the parameters of the obtained font style transfer network can be inherited and reused as initial parameters for subsequent training.

[0215] By using the pre-trained font style transfer network parameters as the initial parameters, compared with setting random initial parameters, the training effect and training speed of the preset font style transfer network can be improved, and the requirement for the number of samples can be reduced.

[0216] 3. The following explains in detail how to obtain the pre-trained network.

[0217] Optionally, a pre-trained font style transfer network may be obtained. For ease of description, the obtained font style transfer network is referred to as an “initial font style transfer network”.

[0218] Afterwards, the structure of the initial font style transfer network can be adjusted, and the corresponding parameters can be inherited as initial parameters to obtain the preset font style transfer network before training.

[0219] This embodiment does not limit the specific structural adjustment, as long as it can be adjusted to a preset font style transfer network.

[0220] Optionally, the specific structural adjustment may include adding feature input of sampling information of the original character image, and cascading the feature input of the sampling information to the preset generation model, so that the preset generation model can extract features based on the sampling information.

[0221] Optionally, the specific structural adjustment may include adding feature input of the sampling information of the original character image, and cascading the feature input of the sampling information to the encoder in the preset generation model, so that the features of the sampling information can be input to the encoder in the preset generation model, so that the preset generation model can extract features based on the sampling information.

[0222] Optionally, the specific structural adjustment may include adding a feature input of the sampling information of the original character image and a new sampling information encoder, cascading the feature input of the sampling information to the newly added sampling information encoder, and cascading the output of the sampling information encoder to the input of the decoder.

[0223] Thus, the features of the sampling information can be input into the sampling information encoder, and the output of the sampling information encoder can be directly input into the decoder.

[0224] In addition, this embodiment does not limit the structure and training method of the initial font style transfer network.

[0225] Optionally, the structure of the initial font style transfer network can adopt a structure in which the generative model only includes an image encoder and a decoder, or a structure in which the generative model includes an image encoder, a sampling information encoder and a decoder, or a structure in which the generative model includes an image encoder, a font style encoder and a decoder, and so on.

[0226] Optionally, the initial font style transfer network can be trained using multi-label character image samples, that is, the same original character image can correspond to samples of different target character images. The initial font style transfer network can also be trained using the preset character image sample set in S102. The initial font style transfer network can also be trained using mixed multi-label character image samples and the preset character image sample set.

[0227] The pre-trained initial font style transfer network can learn a certain font style transfer capability, thereby providing better network parameters and helping to set the initial parameters of the preset font style transfer network.

[0228] Compared with setting random initial parameters, this method can improve the training effect and speed of the preset font style transfer network and reduce the requirement for the number of samples.

[0229] In an optional embodiment, obtaining a preset font style transfer network may include: obtaining a pre-trained initial font style transfer network; the initial font style transfer network is a generative adversarial network, including an initial generative model and an initial discriminant model; the initial generative model can be used to generate a second migration initial image for a second original character image, and the initial discriminant model can be used to predict the probability that the second migration initial image is a target character image; and converting the initial font style transfer network into a preset font style transfer network.

[0230] Optionally, converting the initial font style transfer network into a preset font style transfer network may include: adding a sampling information encoder for encoding the sampling information of the original character image to the initial generation model in the initial font style transfer network, and cascading the output of the sampling information encoder to the input of the decoder in the initial generation model to obtain the preset generation model; and determining the initial discriminant model as the preset discriminant model.

[0231] Optionally, the initial generative model may include an image encoder and decoder. When converting the initial font style transfer network to the preset font style transfer network, the image encoder and decoder in the initial generative model may be used as the image encoder and decoder in the preset generative model. Specifically, the specific structures and parameters of the image encoder and decoder may be directly reused.

[0232] Optionally, a sampling information encoder is specifically added, and the feature input of the sampling information of the original character image can be cascaded to the input of the sampling information encoder, and the output of the sampling information encoder can be cascaded to the input of the decoder in the preset generation model.

[0233] This embodiment does not limit the training method of the initial font style transfer network.

[0234] Optionally, obtaining a pre-trained initial font style transfer network may include: training the initial font style transfer network to obtain the pre-trained initial font style transfer network. Training the initial font style transfer network may include: obtaining an initial character image sample set, the initial character image sample set including a plurality of second character image samples, the second character image samples including a second original character image and a second target character image, the second original character image being a sample feature, the second target character image being a sample label, the second original character image and the second target character image in the same second character image sample representing the same character; and training the initial font style transfer network using the initial character image sample set.

[0235] Optionally, a character image in a handwriting style may be used as the second original character image, and a character image in a specified font style may be used as the second target character image.

[0236] Optionally, the second original character image may include a character image in a handwriting style; and the second target character image may include a character image in a printed font style.

[0237] Optionally, the printed font style may specifically include a standard font style for a printed version, such as Songti, Heiti, Kaiti, and the like.

[0238] Optionally, the training method of the initial font style transfer network may include: obtaining an initial character image sample set; the features of the character image samples in the initial character image sample set include a second original character image, and the labels of the character image samples include a second target character image; the second original character image and the second target character image in the same character image sample represent the same character; and using the initial character image sample set to train the initial font style transfer network.

[0239] The specific conditions of the samples in the initial character image sample set are not limited.

[0240] Optionally, there may be different second target character images corresponding to different second original character images, or there may be the same second original character image corresponding to different second target character images.

[0241] Optionally, the character image sample in the combination of the initial character image samples is referred to as a second character image sample, for distinguishing from the first character image sample. The second character image sample and the first character image sample may have different structures. The sample features of the second character image sample include the original character image, while the sample features of the first character image sample include the original character image and sampling information of the original character image.

[0242] Optionally, the second original character image is used to distinguish from the sample features (first original character image) in the preset character image sample set. The second original character image belongs to the original character image, and the original character image contained in the sample features in the initial character image sample set is called the second original character image. Optionally, the second original character image can be the same as the first original character image in form, and the content can be the same or different. The second target character image is interpreted similarly.

[0243] 2. S102: Obtain a preset character image sample set.

[0244] Optionally, the preset character image sample set may include multiple first character image samples, the first character image sample may include the first original character image, sampling information of the first original character image and the first target character image, the first original character image and the sampling information of the first original character image are sample features, the first target character image is the sample label, and the first original character image and the first target character image in the same character image sample represent the same character.

[0245] Optionally, the preset character image sample set includes a plurality of first target character images representing the same character, and different first target character images representing the same character correspond to different first original character images.

[0246] 1. About sampling information.

[0247] The process of this method is not limited to specific sampling information.

[0248] Optionally, the sampling information may include: character sampling point position information and / or character trajectory position information.

[0249] Optionally, when the sampling information includes character sampling point position information, the sampling information may further include character sampling point order information; and / or when the sampling information includes character trajectory position information, the sampling information may further include character trajectory order information.

[0250] Optionally, the character sampling point position information may represent the position information of the sampled points in the character image, and the character sampling point order information may represent the sampling order between different sampled points in the character image.

[0251] Of course, this embodiment does not limit the specific character sampling method.

[0252] For ease of understanding, in an optional specific example, a fixed number of sampling points may be sampled for each line in the character image. Based on the position information of the sampling points, the distance between the sampling points can be determined, and further, the length and tilt of the line can be determined. The sampling point order information may specifically be from top to bottom or from left to right.

[0253] This embodiment does not limit the form of the character trajectory. Specifically, the trajectory in the character can be represented in the form of points, that is, trajectory points, or in the form of lines, that is, trajectory lines.

[0254] Optionally, the character track position information may include track point position information and / or track line position information. The character track order information may include the writing order of each track in the character image, and may be specifically used to represent the stroke order.

[0255] For ease of understanding, in an optional specific example, the writing sequence of each track during the writing process of the character image can be sampled, and specifically, a track point set with a sequence or a track line set with a sequence can be obtained.

[0256] This embodiment does not limit the specific method for obtaining sampling information.

[0257] Optionally, the sampling information may be obtained by sampling the writing trajectory of the first original character image to obtain the sampling information.

[0258] Optionally, sampling the writing trajectory of the original character image to obtain sampling information may include: sampling the writing trajectory of the original character image on the touch screen, obtaining a trajectory with a time sequence relationship and determining it as the sampling information.

[0259] In a specific example, the touch screen can be a handwriting screen, so that sampling can be performed based on the trajectory of the user's writing on the handwriting screen to obtain a trajectory with a time sequence relationship. For example, the touch screen includes an infrared touch component or a capacitive touch component, and the touch component is used to capture the touch trajectory points of the user during the handwriting process. The touch component sends the above-mentioned supplementary touch trajectory points to the SOC (system-on-chip), and the SOC saves the received touch trajectory points as sampling information and generates text, that is, the first original character image, based on the received touch trajectory points. Alternatively, the SOC can sparsely sample the received touch trajectory points and save the sparsely sampled trajectory point information as sampling information. Specifically, it can be trajectory points with a time sequence relationship or the order of written strokes.

[0260] Optionally, the sampling information may be acquired by sampling the first original character image to obtain the sampling information.

[0261] 2. About how to obtain the sample set.

[0262] The present method does not limit the specific method for obtaining the preset character image sample set, as long as different first target character images representing the same character correspond to different first original character images.

[0263] Optionally, multiple different character images representing the same character can be obtained, some of which can be determined as N different first target character images, and the remaining character images can be divided into N different subsets that have no intersection with each other, corresponding to the N first target character images respectively.

[0264] Therefore, each character image can be obtained from the subset corresponding to the first target character image as the first original character image, and sampling information of the first original character image can be determined to form a first character image sample and add it to the preset character image set.

[0265] In an optional embodiment, in order to facilitate faster convergence of the font style transfer network during training, when obtaining character image samples in a preset character image sample set, a character image that is close or similar to the first target character image can be determined as a first original character image based on a first target character image, so that by learning the close or similar font styles between the first original character image and the first target character image, the trained preset font style transfer network can migrate to a close or similar font style for the input character image.

[0266] The character image that is close to or similar to the first target character image can be determined by calculating image similarity. If the image similarity to the first target character image is greater than a preset similarity threshold, it can be considered to be a character image that is close to or similar to the first target character image.

[0267] Optionally, different first target character images representing the same character may have different font styles. The target font style transfer network can be used to: output transfer result character images with different font styles for different character image inputs representing the same character.

[0268] Optionally, the preset generative model in the target font style transfer network can be used to: output a transfer result character image with a similar font style for a character image input.

[0269] Optionally, the preset generative model in the target font style transfer network can have the following function: for different character image inputs representing the same character, outputting transfer result character images with similar font styles. The preset generative model can be used to output transfer result character images with similar font styles for different character image inputs representing the same character.

[0270] The font styles of the outputted migration result character images are allowed to be different.

[0271] Optionally, different first target character images representing the same character may have different font styles; the preset generation model in the target font style transfer network may have the following functions: for different character image inputs representing the same character, output transfer result character images with different font styles.

[0272] As an exemplary illustration, the embodiments of the present invention provide the following sample acquisition methods.

[0273] Optionally, the method for obtaining the first character image sample in the preset character image sample set may include: determining different character images representing the same character and having different font styles as first target character images respectively; obtaining sample features according to the determined first target character images respectively to obtain the first character image sample.

[0274] Specifically, for each first target character image, a different first original character image is generated or obtained, and sampling information is determined for the obtained first original character image to obtain a first character image sample, and the obtained first character image sample is added to a preset character image sample set.

[0275] This embodiment does not limit the method of obtaining sample features for the first target character image.

[0276] Optionally, obtaining sample features respectively according to the determined first target character image may include at least one of the following:

[0277] 1) For any determined first target character image, at least one first original character image is obtained through image enhancement processing, and sampling information is determined for the obtained first original character image.

[0278] 2) For any determined first target character image, determine at least one character image having an image similarity with the first target character image higher than a preset similarity as a first original character image, and determine sampling information for the determined first original character image.

[0279] 3) For any determined first target character image, obtain at least one character image of the copied writing, determine it as a first original character image, and determine sampling information for the determined first original character image.

[0280] For ease of understanding, in an optional embodiment, training and learning can be performed based on individual handwriting style.

[0281] In an optional embodiment, in order to facilitate faster convergence of the font style transfer network during training, when obtaining character image samples in a preset character image sample set, a character image that is close or similar to the first target character image can be determined as a first original character image based on a first target character image, so that by learning the close or similar personal handwriting style between the first original character image and the first target character image, the trained preset font style transfer network can migrate to a close or similar personal handwriting style for the input character image.

[0282] Optionally, different first target character images representing the same character may have different handwriting styles. The preset generative model in the target font style transfer network can be used to: output transfer result character images with different handwriting styles for different character image inputs representing the same character.

[0283] Optionally, the preset generative model in the target font style transfer network can be used to: for character image input, output a transfer result character image with a similar personal handwriting style.

[0284] Optionally, the preset generative model in the target font style transfer network can have the following function: for different character image inputs representing the same character, outputting a transferred character image with a similar personal handwriting style. The preset generative model can be used to: for different character image inputs representing the same character, outputting a transferred character image with a similar personal handwriting style.

[0285] The outputted migration result character image is allowed to have different personal handwriting styles.

[0286] Optionally, different first target character images representing the same character may have different handwriting styles; the preset generation model in the target font style transfer network may have the following functions: for different character image inputs representing the same character, outputting transfer result character images with different handwriting styles.

[0287] Since we need to learn a variety of different personal handwriting styles, when actually collecting character image generation samples, we can ask the same person to repeatedly write the same character multiple times, so that we can easily collect character images with the same or similar personal handwriting styles for generating samples.

[0288] In an optional specific example, each data collector can write each common Chinese character multiple times. Thus, for each data collector, multiple character images of each common Chinese character can be obtained. These character images can be used as training data, and the labels of these training data can be each Chinese character copied by each data collector. Specifically, it can be each Chinese character formally copied by each data collector alone.

[0289] Optionally, one character image can be selected from multiple character images of each Chinese character written by each data collector as the target character image, and the remaining other character images can be used as the first original character images.

[0290] For the sake of easy understanding, for example, a data collector can formally copy the Chinese character "专" in Song typeface to obtain a "专" character image with personal handwriting style as the first target character image.

[0291] After that, the same data collector can write the character "专" multiple times to obtain multiple "专" character images as the respective first original character images for generating samples, so that first original character images and a first target character image with the same or similar personal handwriting style can be obtained.

[0292] As an exemplary illustration, the embodiments of the present invention provide the following several sample acquisition methods.

[0293] Optionally, the method for obtaining character image samples in the preset character image sample set may include: respectively determining different character images representing the same character and having different personal handwriting styles as the first target character images; respectively obtaining sample features according to the determined first target character images to obtain the first character image samples. Specifically, for each of the first target character images, different first original character images can be generated or obtained respectively, and sampling information can be determined for the obtained first original character images, and then the first character image samples can be obtained, and the obtained first character image samples can be added to the preset character image sample set.

[0294] This embodiment does not limit the manner of obtaining sample features for the first target character images.

[0295] Optionally, respectively obtaining sample features according to the determined first target character images may include at least one of the following.

[0296] 1) For any one of the determined first target character images, through image enhancement processing, at least one first original character image is obtained, and sampling information is determined for the obtained first original character images.

[0297] 2) For any determined first target character image, determine at least one character image having an image similarity with the first target character image higher than a preset similarity as a first original character image, and determine sampling information for the determined first original character image.

[0298] 3) For any determined first target character image, obtain at least one character image of the copied writing, determine it as a first original character image, and determine sampling information for the determined first original character image.

[0299] 4) For any determined first target character image, at least one character image obtained by handwriting the character represented by the first target character image based on the same handwriting style is determined as a first original character image, and sampling information is determined for the determined first original character image.

[0300] Optionally, the method for obtaining character image samples in a preset character image sample set may include: obtaining different character images handwritten by different people for the same character; different people have different handwriting styles; wherein the number of character images handwritten by the same person for the same character based on the same handwriting style is greater than or equal to 2; among the character images handwritten by the same person, determining any character image as the first target character image, determining other character images as the first original character images, and determining sampling information for the determined first original character image to obtain a first character image sample.

[0301] S103: Using a preset character image sample set to train a preset font style transfer network to obtain a target font style transfer network.

[0302] The present method does not limit the specific training method. Alternatively, adversarial learning can be used. The present method does not limit the specific structure and specific discrimination method of the preset discriminant model.

[0303] The above method process, by using character image samples to train a preset font style transfer network, can enable the trained preset font style transfer network to be used for font style transfer of character images, thereby facilitating font style transfer of character images.

[0304] Moreover, by using different target character images representing the same character and different character image samples including different original character images, a preset font style transfer network of a generative adversarial network structure is trained, so that different font styles of the same character (that is, different font styles included in different target character images) can be learned, so that the trained target font style transfer network can migrate to different font styles for different character images representing the same character, without specifying the migration target font style, thereby allowing for more flexible font style transfer.

[0305] In addition, it should be noted that since the preset font style transfer network trained in the process of this method needs to learn different font styles of the same character, in order to improve the convergence speed and reduce the convergence difficulty, the sampling information of the original character image can be added as the new feature input of the preset font style transfer network, thereby increasing the constraints and reducing the learning search range of the network, which is beneficial to the convergence of the network.

[0306] The above method can also improve the structure of the font style transfer network by adding a sampling information encoder to form a new network structure.

[0307] Based on the target font style transfer network trained by the above method embodiment, an embodiment of the present invention further provides a font style transfer method.

[0308] As shown in FIG3 , FIG3 is a flow chart of a font style transfer method according to an embodiment of the present invention.

[0309] The embodiment of the present invention does not limit the execution subject of the method process. Optionally, the execution subject can be any computing device. For example, a server for font style migration, or a terminal that needs to perform font style migration.

[0310] The method may include the following steps.

[0311] S201: Acquire a character image to be migrated and sampling information of the character image to be migrated.

[0312] S202: Inputting the acquired character image to be transferred and sampling information into a preset generation model in a pre-trained target font style transfer network, and determining the output of the preset generation model as a transfer result character image.

[0313] Optionally, the target font style transfer network may be trained through any of the above method embodiments.

[0314] This method does not limit the specific method for obtaining sampling information.

[0315] Optionally, a method for acquiring the sampling information of the character image to be migrated may include: sampling the writing trajectory of the character image to be migrated to obtain the sampling information.

[0316] Optionally, sampling the writing trajectory of the character image to be migrated to obtain sampling information may include: sampling the writing trajectory of the character image to be migrated on the touch screen, obtaining a trajectory with a time sequence relationship and determining it as the sampling information.

[0317] Optionally, a method for acquiring sampling information of the character image to be migrated may include: sampling the character image to be migrated to obtain sampling information.

[0318] For specific related explanations, please refer to the explanation of the above method embodiment.

[0319] For ease of understanding, the embodiment of the present invention further provides an application embodiment.

[0320] When writing Chinese characters on the screen, you may want to beautify each font to a certain extent, such as converting your own font into a calligraphy font, but at the same time you may want the converted calligraphy font to retain the style of the original font to a certain extent.

[0321] This solution hopes that the original handwritten font can be close to a certain calligraphy font (such as regular script) while retaining the personal handwriting style to a certain extent.

[0322] Therefore, this solution made adjustments when setting labels. The labels are no longer standard calligraphy font images, but handwritten character images obtained by data collectors copying calligraphy fonts, so that different labels have differences in each character.

[0323] At the same time, to address the problem of difficult training of generative adversarial networks in font style transfer, this solution introduces trajectory points as auxiliary training branches, making the network training process easier to converge.

[0324] The specific application scenarios of this solution can include: smart blackboards, large conference screens, and other offices, conferences, exhibitions and other places.

[0325] The goal of this solution is to convert Chinese characters into a calligraphy-style font when writing on a handwriting screen for use in educational settings, office meetings, or exhibitions. At the same time, we also want to ensure that the fonts generated do not look identical for different handwritings, i.e., maintain a sense of uniqueness. This requirement necessitates the use of generative adversarial networks for Chinese character generation.

[0326] The following is a brief introduction to this plan.

[0327] This embodiment proposes a method for handwritten Chinese character style transfer for Chinese character generation. In the scenario of a handwriting screen, it is desired to convert temporarily handwritten Chinese characters into a font with a calligraphy style, such as converting them into the regular script of Ouyang Xun, while still retaining some personal handwriting styles of the original font to a certain extent.

[0328] The solution of this embodiment can combine the trajectory points and character images, and obtain a font that combines the existing calligraphy font style and personal handwriting style through a generative adversarial network.

[0329] In the solution of this embodiment, the handwriting trajectory points and character images are used simultaneously as the input of the generative adversarial network, rather than just the character images. At the same time, the label of the model is the calligraphy font copied by each data collector.

[0330] Through this training, the output of the generative model in the generative adversarial network can have both personal handwriting style and calligraphy font style, rather than outputting a single calligraphy font.

[0331] The solution of this embodiment proposes a style transfer method of a generative adversarial network based on handwritten Chinese character trajectory points and character images.

[0332] The basic network of this method can be the zi2zi network often used in the font style transfer network. The input of this network is the original character image. On this basis, this method adds an auxiliary branch to input the trajectory points of the original character image.

[0333] At the same time, the label corresponding to each original character image is the calligraphy font copied by the data collector, so that the font output by the generative model in the generative adversarial network has both personal writing style and calligraphy font style.

[0334] As shown in FIG. 4, FIG. 4 is a schematic diagram of the principle of a font style transfer shown according to an embodiment of the present invention.

[0335] Among them, the first character in each row is the character image input into the generative adversarial network, the second character is the character image generated by the model, specifically, it can be the character image output by the generative model in the generative adversarial network, and the third character is the label (that is, the character image obtained by copying the calligraphy font personally).

[0336] The two rows respectively represent the character "体" written by different people. It can be seen from FIG. 4 that the fonts generated by the model after learning can be aligned with their respective labels, that is, they can be transferred to similar personal handwriting styles respectively.

[0337] Specifically, the manifestation of different personal handwriting styles can be seen through the places circled by the circles.

[0338] The migration of two different “body” character images in FIG4 can be regarded as an example of the migration result of the generative model of the target font style migration network in the embodiment of the above method in a specific use process.

[0339] The following is a detailed explanation of this solution.

[0340] The idea behind this approach is that during the data collection phase, each data collector writes each common Chinese character multiple times. This allows each data collector to obtain multiple character images for each Chinese character. These character images can be used to generate training data, which is labeled with each character image copied by each data collector.

[0341] Optionally, one character may be selected from multiple pictures of each character written by each data collector as a label, and the remaining characters may be used as sample features corresponding to the label.

[0342] Currently, some public datasets are available, but they are not fully suitable for this solution.

[0343] The reason is that this kind of public data basically consists of each person writing different Chinese characters only once, which makes it impossible to pick out one as a label for each Chinese character according to a predetermined idea, and use the rest as training data.

[0344] In order to utilize this data, and based on the characteristics of this data, for each Chinese character, we can find the regular script font of the Chinese character as a label. We hope to first learn from handwritten characters to regular script characters, and pre-train a model so that the model can learn basic font strokes.

[0345] The pre-trained model can use the zi2zi network. The input image size is 256*256, the batch size is set to 32, the training epoch is set to 200, the initial learning rate is 0.002, and the learning rate change rule is to reduce the learning rate to 0.5 times the original every 10 epochs. The hardware used is a V100 GPU.

[0346] Among them, the learning rate is a parameter needed when training the model. During the initial training of the model, since the model parameters are basically randomly initialized, there is a large gap between them and the optimal parameters. In order to find the optimal solution as much as possible, a large learning rate is generally used.

[0347] When retraining with a pre-trained model, since the pre-trained model parameters have been optimized compared to the initial model, it is necessary to reduce the learning rate to avoid excessive perturbations caused by a large learning rate. Therefore, this solution reduces the learning rate to half of the original value before retraining.

[0348] Of course, the reduction in learning rate is not limited here, it can be 0.5 times, 0.3 times, and so on.

[0349] The pre-trained model can learn the style of the font.

[0350] The generator part of the original zi2zi network is an encoder and decoder structure, and its input is a handwritten character image. This structure is effective for migrating ordinary handwritten characters to certain fonts (such as regular script).

[0351] However, for the purpose of including both calligraphy font styles and personal handwriting styles proposed in this scheme, the learning difficulty of the network is increasing, because the personal handwriting styles of the same character are also different (different collectors copy the same character).

[0352] In order to increase the network's constraint capability, narrow the network's learning space, and make the network converge more easily, this solution adds an additional encoder to the generator part of the original zi2zi network to process the trajectory points of the character image. The input is the trajectory points of the original character image, and the output is a feature map. This feature map is channel-superimposed with the feature map generated by the original encoder, allowing the network to simultaneously obtain the trajectory information of the handwritten characters, which is then fed into the subsequent decoder.

[0353] The loss function and parameter settings for the network structure can be kept consistent with the original zi2zi.

[0354] After obtaining the pre-trained model, use the pre-collected training data to train the improved model. During training, the parameters set can be consistent with those during pre-training, except that the initial learning rate is reduced to half of the initial learning rate of the pre-trained model.

[0355] The trained model can migrate character images written by different people to the personal handwriting style of the data collector that is close or similar, and obtain the migration result character image in that style.

[0356] In other words, since the personal handwriting style of the labels provided by each data collector is different, the model is able to migrate different handwritings to different personal handwriting styles.

[0357] The improvements of this solution mainly lie in the new network formed by improving the zi2zi network structure; proposing that the trajectory points of the font can also be used as auxiliary input information in font style transfer; and being able to achieve handwriting style transfer that includes both calligraphy font styles and personal handwriting styles through model training.

[0358] Corresponding to the above method embodiment, the embodiment of the present invention further provides an apparatus embodiment.

[0359] As shown in FIG5 , FIG5 is a structural diagram of a training device for a font style transfer network according to an embodiment of the present invention.

[0360] The apparatus may include the following units.

[0361] The network acquisition unit 301 is used to acquire a preset font style transfer network; the preset font style transfer network is a generative adversarial network;

[0362] The sample acquisition unit 302 is used to obtain a preset character image sample set; the features of the character image samples in the preset character image sample set include a first original character image and sampling information of the first original character image, and the labels of the character image samples include a target character image; the first original character image and the target character image in the same character image sample represent the same character.

[0363] Optionally, the preset character image sample set may include multiple first target character images representing the same character, and different first target character images representing the same character may correspond to different first original character images.

[0364] The training unit 303 is configured to train a preset font style transfer network using a preset character image sample set to obtain a target font style transfer network.

[0365] Optionally, the preset font style transfer network includes a preset generation model and a preset discrimination model;

[0366] The preset generation model is used to generate a migration result image based on the original character image and the sampling information of the original character image, and the preset discrimination model is used to predict the probability that the migration result image is the target character image.

[0367] Optionally, the sampling information includes: character sampling point position information and / or character trajectory position information.

[0368] Optionally, when the sampling information includes character sampling point position information, the sampling information also includes character sampling point order information; and / or when the sampling information includes character trajectory position information, the sampling information also includes character trajectory order information.

[0369] Optionally, the sampling information is obtained by sampling the writing trajectory of the first original character image to obtain the sampling information.

[0370] Optionally, sampling the writing trajectory of the first original character image to obtain sampling information includes: sampling the writing trajectory of the first original character image on the touch screen to obtain a trajectory with a temporal sequence relationship and determining it as the sampling information.

[0371] Optionally, the sampling information is obtained by sampling the first original character image to obtain the sampling information.

[0372] Optionally, the preset generation model includes an image encoder, a sampling information encoder and a decoder; the preset generation model is used to: use the image encoder to extract image features from the original character image, use the sampling information encoder to extract sampling information features from the sampling information of the original character image, perform channel superposition on the extracted image features and the sampling information features to obtain a channel superposition result, and use the decoder to generate a migration result image based on the obtained channel superposition result.

[0373] Optionally, the network acquisition unit 301 is used to: obtain a pre-trained initial font style transfer network, the initial font style transfer network is a generative adversarial network, including an initial generative model and an initial discriminant model; the initial generative model is used to generate a second migration initial image for the second original character image, and the initial discriminant model is used to predict the probability that the second migration initial image is the target character image; convert the initial font style transfer network into a preset font style transfer network, including: adding a sampling information encoder for encoding the sampling information of the original character image to the initial generative model in the initial font style transfer network, and cascading the output of the sampling information encoder to the input of the decoder in the initial generative model to obtain a preset generative model, and determining the initial discriminant model as the preset discriminant model.

[0374] Optionally, the network acquisition unit 301 is used to: train the initial font style transfer network to obtain a pre-trained initial font style transfer network; wherein the network acquisition unit 301 is used to: obtain an initial character image sample set, the initial character image sample set includes multiple second character image samples, the second character image samples include a second original character image and a second target character image, the second original character image is a sample feature, the second target character image is a sample label, and the second original character image and the second target character image in the same second character image sample represent the same character; use the initial character image sample set to train the initial font style transfer network.

[0375] Optionally, the second original character image includes: a character image in handwriting style; and the second target character image includes: a character image in printed font style.

[0376] Optionally, different first target character images representing the same character have different font styles; the preset generation model in the target font style transfer network has the following function: for different character image inputs representing the same character, outputting transfer result character images with different font styles.

[0377] Optionally, a method for obtaining character image samples in a preset character image sample set includes: determining different character images representing the same character and having different font styles as first target character images; and obtaining sample features based on the determined first target character images to obtain first character image samples.

[0378] Optionally, obtaining sample features respectively according to the determined first target character image includes at least one of the following:

[0379] For any determined first target character image, perform image enhancement processing to obtain at least one first original character image, and determine sampling information for the obtained first original character image;

[0380] For any determined first target character image, determining at least one character image having an image similarity with the first target character image higher than a preset similarity as a first original character image, and determining sampling information for the determined first original character image;

[0381] For any determined first target character image, at least one character image of the copied writing is obtained and determined as a first original character image, and sampling information is determined for the determined first original character image.

[0382] Optionally, different first target character images representing the same character have different handwriting styles; the preset generation model in the target font style transfer network has the following function: for different character image inputs representing the same character, outputting transfer result character images with different handwriting styles.

[0383] Optionally, a method for obtaining character image samples in a preset character image sample set includes: determining different character images representing the same character and having different handwriting styles as first target character images; and obtaining sample features based on the determined first target character images to obtain first character image samples.

[0384] Optionally, obtaining sample features respectively according to the determined first target character image includes at least one of the following:

[0385] For any determined first target character image, perform image enhancement processing to obtain at least one first original character image, and determine sampling information for the obtained first original character image;

[0386] For any determined first target character image, determining at least one character image having an image similarity with the first target character image higher than a preset similarity as a first original character image, and determining sampling information for the determined first original character image;

[0387] For any determined first target character image, obtaining at least one character image of the copied writing, determining it as a first original character image, and determining sampling information for the determined first original character image;

[0388] For any determined first target character image, at least one character image obtained by handwriting the character represented by the first target character image based on the same handwriting style is determined as a first original character image, and sampling information is determined for the determined first original character image.

[0389] Optionally, the method for obtaining character image samples from the preset character image sample set includes:

[0390] Obtain different character images of the same character written by different people, and different people have different handwriting styles;

[0391] The number of character images obtained by the same person for the same character using the same handwriting style is greater than or equal to 2;

[0392] Among the character images handwritten by the same person, any character image is determined as a first target character image, and the other character images are determined as first original character images. Sampling information is determined for the determined first original character image to obtain a character image sample.

[0393] For detailed explanation, please refer to the above method embodiment.

[0394] As shown in FIG6 , FIG6 is a structural diagram of a training device for a font style transfer network according to an embodiment of the present invention.

[0395] The apparatus may include the following units.

[0396] The acquiring unit 401 is configured to acquire a character image to be migrated and sampling information of the character image to be migrated.

[0397] The migration unit 402 is used to input the acquired character image to be migrated and sampling information into a preset generation model in a pre-trained target font style migration network, and determine the output of the preset generation model as the migration result character image; the target font style migration network is obtained by training through the above-mentioned device embodiment.

[0398] Optionally, the target font style transfer network may be obtained by training through any of the above method embodiments or device embodiments.

[0399] This method does not limit the specific method for obtaining sampling information.

[0400] Optionally, a method for acquiring the sampling information of the character image to be migrated may include: sampling the writing trajectory of the character image to be migrated to obtain the sampling information.

[0401] Optionally, sampling the writing trajectory of the character image to be migrated to obtain sampling information may include: sampling the writing trajectory of the character image to be migrated on the touch screen, obtaining a trajectory with a time sequence relationship and determining it as the sampling information.

[0402] Optionally, a method for acquiring sampling information of the character image to be migrated may include: sampling the character image to be migrated to obtain sampling information.

[0403] For detailed explanation, please refer to the above method embodiment.

[0404] An embodiment of the present invention further provides a computer device, which includes at least a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, any one of the above method embodiments is implemented.

[0405] An embodiment of the present invention also provides an electronic device, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions that can be executed by the one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute any of the above-mentioned method embodiments.

[0406] FIG7 is a schematic diagram of the hardware structure of a computer device configured to implement the method according to an embodiment of the present invention, according to an embodiment of the present invention. The device may include: a processor 1010, a memory 1020, an input / output interface 1030, a communication interface 1040, and a bus 1050. The processor 1010, the memory 1020, the input / output interface 1030, and the communication interface 1040 are connected to each other within the device via the bus 1050.

[0407] The processor 1010 can be implemented using a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided by the embodiments of the present invention.

[0408] The memory 1020 can be implemented in the form of ROM (Read Only Memory), RAM (Random Access Memory), static storage devices, dynamic storage devices, etc. The memory 1020 can store an operating system and other application programs. When the technical solutions provided by the embodiments of the present invention are implemented through software or firmware, the relevant program codes are stored in the memory 1020 and are called and executed by the processor 1010.

[0409] The input / output interface 1030 is used to connect input / output modules to implement information input and output. The input / output modules can be configured as components within the device (not shown in the figure) or can be externally connected to the device to provide corresponding functions. Input devices may include a keyboard, mouse, touch screen, microphone, various sensors, etc., and output devices may include a display, speaker, vibrator, indicator light, etc.

[0410] The communication interface 1040 is used to connect to a communication module (not shown) to enable communication between the device and other devices. The communication module can communicate via a wired method (such as USB, network cable, etc.) or a wireless method (such as mobile network, WiFi, Bluetooth, etc.).

[0411] The bus 1050 comprises a path for transmitting information between the various components of the device (eg, the processor 1010 , the memory 1020 , the input / output interface 1030 , and the communication interface 1040 ).

[0412] It should be noted that although the above device only shows the processor 1010, the memory 1020, the input / output interface 1030, the communication interface 1040, and the bus 1050, in a specific implementation, the device may also include other components necessary for normal operation. In addition, those skilled in the art will understand that the above device may only include the components necessary to implement the embodiments of the present invention, and does not necessarily include all the components shown in the figure.

[0413] An embodiment of the present invention further provides a computer-readable storage medium having a computer program stored thereon, which implements any of the above method embodiments when executed by a processor.

[0414] An embodiment of the present invention further provides a computer-readable storage medium storing a computer program, wherein the computer program implements any of the above method embodiments when executed by a processor.

[0415] Computer-readable media includes permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. The information can be computer-readable instructions, data structures, program modules, 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 disc (DVD) or other optical storage, magnetic cassettes, magnetic disk storage or other magnetic storage devices, or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer-readable media does not include transitory media such as modulated data signals and carrier waves.

[0416] Through the description of the above embodiments, it can be seen that those skilled in the art can clearly understand that the embodiments of the present invention can be implemented by means of software plus the necessary general hardware platform. Based on this understanding, the technical solution of the embodiments of the present invention can essentially or in other words, the contributing part can be embodied in the form of a software product. The computer software product can be stored in a storage medium such as ROM / RAM, a magnetic disk, an optical disk, etc., and includes a number of instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in various embodiments or certain parts of the embodiments of the present invention.

[0417] The systems, devices, modules, or units described in the above embodiments may be implemented by computer chips or entities, or by products having certain functions. A typical implementation device is a computer, which may be in the form of a personal computer, laptop computer, cellular phone, camera phone, smartphone, personal digital assistant, media player, navigation device, email transceiver, game console, tablet computer, wearable device, or any combination of these devices.

[0418] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment. The device embodiment described above is merely illustrative, wherein the modules described as separate components may or may not be physically separated, and when implementing the embodiment of the present invention, the functions of each module can be implemented in the same one or more software and / or hardware. It is also possible to select some or all of the modules according to actual needs to achieve the purpose of the embodiment. A person of ordinary skill in the art can understand and implement it without paying any creative work.

[0419] The above description is only a specific implementation of the embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the embodiment of the present invention. These improvements and modifications should also be regarded as protection for the embodiment of the present invention.

[0420] In the present invention, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance. The term "plurality" refers to two or more, unless otherwise clearly defined.

[0421] Other embodiments of the present invention will readily occur to those skilled in the art after considering the specification and practicing the disclosure herein. The present invention is intended to cover any variations, uses, or adaptations of the present invention that follow the general principles of the invention and include common knowledge or customary techniques in the art not disclosed herein. The description and examples are to be considered as exemplary only, with the true scope and spirit of the invention being indicated by the following claims.

[0422] It should be understood that the present invention is not limited to the exact construction described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present invention is limited only by the appended claims.

Claims

1. A training method for a font style transfer network, characterized in that: include: Obtaining a preset font style transfer network, wherein the preset font style transfer network is a generative adversarial network; Obtaining a preset character image sample set, wherein the preset character image sample set includes a plurality of first character image samples, the first character image sample including a first original character image, sampling information of the first original character image, and a first target character image, the first original character image and the sampling information of the first original character image being sample features, the first target character image being a sample label, and the first original character image and the first target character image in the same character image sample representing the same character; The preset character image sample set is used to train the preset font style transfer network to obtain a target font style transfer network.

2. The method according to claim 1, characterized in that The preset character image sample set includes a plurality of first target character images representing the same character, and different first target character images representing the same character correspond to different first original character images.

3. The method according to claim 1, characterized in that The preset font style transfer network includes a preset generation model and a preset discrimination model; The preset generation model is used to generate a migration result image based on an original character image and sampling information of the original character image, and the preset discrimination model is used to predict the probability that the migration result image is a target character image.

4. The method according to claim 1, wherein The sampling information includes: character sampling point position information and / or character trajectory position information.

5. The method according to claim 4, characterized in that In the case where the sampling information includes character sampling point position information, the sampling information also includes character sampling point sequence information; and / or In the case where the sampling information includes character trajectory position information, the sampling information also includes character trajectory order information.

6. The method according to claim 1, characterized in that The method for obtaining the sampling information includes: Sampling is performed on the writing trajectory of the first original character image to obtain sampling information.

7. The method according to claim 6, characterized in that The sampling of the writing trajectory of the first original character image to obtain sampling information includes: The writing trajectory of the first original character image on the touch screen is sampled to obtain a trajectory with a time sequence relationship and determine it as sampling information.

8. The method according to claim 1, characterized in that The method for obtaining the sampling information includes: Sampling is performed on the first original character image to obtain sampling information.

9. The method according to claim 3, characterized in that The preset generation model includes an image encoder, a sampling information encoder and a decoder; The preset generation model is used to: use the image encoder to extract image features from the original character image, use the sampling information encoder to extract sampling information features from the sampling information of the original character image, perform channel superposition on the extracted image features and sampling information features to obtain channel superposition results, and use the decoder to generate a migration result image based on the obtained channel superposition results.

10. The method according to claim 3, characterized in that The step of obtaining a preset font style transfer network includes: Obtaining a pre-trained initial font style transfer network, where the initial font style transfer network is a generative adversarial network, including an initial generative model and an initial discriminative model; The initial generation model is used to generate a second migration initial image for the second original character image, and the initial discrimination model is used to predict the probability that the second migration initial image is a target character image; The initial font style transfer network is converted into a preset font style transfer network, including: adding a sampling information encoder for encoding sampling information of the original character image to an initial generation model in the initial font style transfer network, and cascading the output of the sampling information encoder to the input of a decoder in the initial generation model to obtain a preset generation model, and determining the initial discriminant model as the preset discriminant model.

11. The method according to claim 10, characterized in that The obtaining of the pre-trained initial font style transfer network comprises: training the initial font style transfer network to obtain the pre-trained initial font style transfer network; The step of training the initial font style transfer network includes: Acquire an initial character image sample set, the initial character image sample set including a plurality of second character image samples, the second character image samples including the second original character image and the second target character image, the second original character image being a sample feature, the second target character image being a sample label, and the second original character image and the second target character image in the same second character image sample representing the same character; The initial font style transfer network is trained using the initial character image sample set.

12. The method according to claim 11, characterized in that The second original character image includes: a character image in a handwriting style; The second target character image includes a character image in a printed font style.

13. The method according to claim 2, characterized in that The different first target character images representing the same character have different font styles; The preset generation model in the target font style transfer network has the following functions: for different character image inputs representing the same character, outputting transfer result character images with different font styles.

14. The method according to claim 2, characterized in that The method for obtaining character image samples from the preset character image sample set includes: Determine different character images representing the same character and having different font styles as first target character images respectively; Sample features are respectively acquired according to the determined first target character image to obtain first character image samples.

15. The method according to claim 14, characterized in that The acquiring of sample features respectively according to the determined first target character image includes at least one of the following: For any determined first target character image, perform image enhancement processing to obtain at least one first original character image, and determine sampling information for the obtained first original character image; For any determined first target character image, determining at least one character image having an image similarity with the first target character image higher than a preset similarity as a first original character image, and determining sampling information for the determined first original character image; For any determined first target character image, at least one character image of the copied writing is obtained and determined as a first original character image, and sampling information is determined for the determined first original character image.

16. The method according to claim 2, characterized in that The different first target character images representing the same character have different handwriting styles; The preset generation model in the target font style transfer network has the following functions: for different character image inputs representing the same character, outputting transfer result character images with different handwriting styles.

17. The method according to claim 2, characterized in that The method for obtaining character image samples from the preset character image sample set includes: Determine different character images representing the same character and having different handwriting styles as first target character images respectively; Sample features are respectively acquired according to the determined first target character image to obtain first character image samples.

18. The method according to claim 17, characterized in that The acquiring of sample features respectively according to the determined first target character image includes at least one of the following: For any determined first target character image, perform image enhancement processing to obtain at least one first original character image, and determine sampling information for the obtained first original character image; For any determined first target character image, determining at least one character image having an image similarity with the first target character image higher than a preset similarity as a first original character image, and determining sampling information for the determined first original character image; For any determined first target character image, obtaining at least one character image of the copied writing, determining it as a first original character image, and determining sampling information for the determined first original character image; For any determined first target character image, at least one character image obtained by handwriting the character represented by the first target character image based on the same handwriting style is determined as a first original character image, and sampling information is determined for the determined first original character image.

19. The method according to claim 2, characterized in that The method for obtaining character image samples from the preset character image sample set includes: Obtain different character images of the same character written by different people, and different people have different handwriting styles; The number of character images obtained by the same person for the same character using the same handwriting style is greater than or equal to 2; Among the character images handwritten by the same person, any character image is determined as a first target character image, and the other character images are determined as first original character images. Sampling information is determined for the determined first original character image to obtain a character image sample.

20. A font style transfer method, characterized in that: include: Acquire a character image to be migrated and sampling information of the character image to be migrated; Inputting the acquired character image to be transferred and sampling information into a preset generation model in a pre-trained target font style transfer network, and determining the output of the preset generation model as the transfer result character image; The target font style transfer network is trained by the method according to any one of claims 1 to 19.

21. The method according to claim 20, characterized in that The method for obtaining the sampling information includes: Sampling is performed on the writing trajectory of the character image to be migrated to obtain sampling information.

22. The method according to claim 21, characterized in that The sampling of the writing trajectory of the character image to be migrated to obtain sampling information includes: Sampling is performed on the writing trajectory of the character image to be migrated on the touch screen to obtain a trajectory with a time sequence relationship and determine it as sampling information.

23. The method according to claim 20, characterized in that The method for obtaining the sampling information includes: Sampling is performed on the character image to be migrated to obtain sampling information.

24. A training device for a font style transfer network, characterized in that: include: A network acquisition unit, configured to acquire a preset font style transfer network, wherein the preset font style transfer network is a generative adversarial network; a sample acquisition unit, configured to acquire a preset character image sample set, wherein the preset character image sample set includes a plurality of first character image samples, the first character image sample includes a first original character image, sampling information of the first original character image, and a first target character image, the first original character image and the sampling information of the first original character image being sample features, the first target character image being a sample label, and the first original character image and the first target character image in the same character image sample representing the same character; A training unit is used to train the preset font style transfer network using the preset character image sample set to obtain a target font style transfer network.

25. A font style transfer device, characterized in that: include: An acquiring unit, configured to acquire a character image to be migrated and sampling information of the character image to be migrated; A migration unit, configured to input the acquired character image to be migrated and the sampling information into a preset generation model in a pre-trained target font style migration network, and determine the output of the preset generation model as a migration result character image; The target font style transfer network is obtained by training the device according to claim 24.

26. An electronic device, characterized in that: include: at least one processor; as well as, a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 23.

27. A computer-readable storage medium storing a computer program, characterized in that: The computer program implements the method according to any one of claims 1 to 23 when executed by a processor.

Citation Information

Patent Citations

  • Font style migration method and system based on multi-task generative adversarial network

    CN113421318A

  • Chinese font style migration method based on adaptive generative adversarial network

    CN114139495A

  • Multi-style Chinese calligraphy character image style migration method, system and terminal

    CN115311130A

  • Character conversion device, recording medium containing program for information processing device, reception content display method, and reception content display system

    WO2006095780A1