Character generation method and apparatus, electronic device, and storage medium
AssigneeBeijing Zitiao Network Technology Co., Ltd.
InventorsWei Liu, Fangyue Liu
Life of this patent
Estimating the term…
Abstract
Embodiments of the present invention provide a character generation method and apparatus. an electronic device, and a storage medium. The method comprises: obtaining a character to be displayed and a pre-selected target style type: converting the character to be displayed into a target character corresponding to the target style type, wherein the target character is generated in at least one of the following modes: generating the target character in advance on the basis of a style type conversion model, and generating the target character in real time on the basis of the style type conversion model; and displaying the target character on a target display interface.
Claims20
A method for generating a character, comprising:
- obtaining a character to be displayed and a pre-selected target style type;
- converting the character to be displayed into a target character corresponding to the target style type, wherein the target character is generated in at least one of modes:
- generating the target character in advance on the basis of a style type conversion model or generating the target character in real time on the basis of a style type conversion model, and wherein the style type conversion model comprises a first font feature extraction sub-model and a second font feature extraction sub-model;
- displaying the target character on a target display interface;
- and
- wherein the method further comprises conducting training to obtain the first font feature extraction sub-model and the second font feature extraction sub-model, wherein conducting the training comprises:
- obtaining a first training sample set, wherein the first training sample set comprises a plurality of first training samples, and each first training sample comprises a theoretical character image and a theoretical character stroke corresponding to a first training character, and a mask character stroke that masks part of the theoretical character stroke,
- inputting, for the plurality of first training samples, a theoretical character image and a mask character stroke in a current first training sample into a to-be-trained font feature extraction sub-model to obtain an actual character image and a predicted character stroke corresponding to the current first training sample,
- conducting loss processing on the actual character image and the theoretical character image on the basis of a first preset loss function in the to-be-trained feature extraction sub-model, and conducting loss processing on the predicted character stroke and the theoretical character stroke on the basis of a second preset loss function to correct a model parameter in the to-be-trained font feature extraction sub-model according to a plurality of loss values obtained,
- setting convergence of the first preset loss function and the second preset loss function as a training target to obtain a to-be-used font feature extraction sub-model, and conducting eliminating processing on the to-be-used font feature extraction sub-model to obtain the first and second font feature extraction sub-models.
An electronic device, comprising:
- one or more processors;
- and a storage apparatus configured to store one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors are caused to implement operations, the operations comprising:
- obtaining a character to be displayed and a pre-selected target style type;
- converting the character to be displayed into a target character corresponding to the target style type, wherein the target character is generated in at least one of modes:
- generating the target character in advance on the basis of a style type conversion model or generating the target character in real time on the basis of a style type conversion model, and wherein the style type conversion model comprises a first font feature extraction sub-model and a second font feature extraction sub-model;
- displaying the target character on a target display interface;
- and
- wherein the operations further comprise conducting training to obtain the first font feature extraction sub-model and the second font feature extraction sub-model, wherein conducting the training comprises:
- obtaining a first training sample set, wherein the first training sample set comprises a plurality of first training samples, and each first training sample comprises a theoretical character image and a theoretical character stroke corresponding to a first training character, and a mask character stroke that masks part of the theoretical character stroke,
- inputting, for the plurality of first training samples, a theoretical character image and a mask character stroke in a current first training sample into a to-be-trained font feature extraction sub-model to obtain an actual character image and a predicted character stroke corresponding to the current first training sample,
- conducting loss processing on the actual character image and the theoretical character image on the basis of a first preset loss function in the to-be-trained feature extraction sub-model, and conducting loss processing on the predicted character stroke and the theoretical character stroke on the basis of a second preset loss function to correct a model parameter in the to-be-trained font feature extraction sub-model according to a plurality of loss values obtained,
- setting convergence of the first preset loss function and the second preset loss function as a training target to obtain a to-be-used font feature extraction sub-model, and
- conducting eliminating processing on the to-be-used font feature extraction sub-model to obtain the first and second font feature extraction sub-models.
A non-transitory computer-readable storage medium comprising a computer-executable instruction, wherein the computer-executable instruction, when being executed by a processor of a computer, is configured to execute operations, the operations comprising:
- obtaining a character to be displayed and a pre-selected target style type;
- converting the character to be displayed into a target character corresponding to the target style type, wherein the target character is generated in at least one of modes:
- generating the target character in advance on the basis of a style type conversion model or generating the target character in real time on the basis of a style type conversion model, and wherein the style type conversion model comprises a first font feature extraction sub-model and a second font feature extraction sub-model;
- displaying the target character on a target display interface;
- and
- wherein the operations further comprise conducting training to obtain the first font feature extraction sub-model and the second font feature extraction sub-model, wherein conducting the training comprises:
- obtaining a first training sample set, wherein the first training sample set comprises a plurality of first training samples, and each first training sample comprises a theoretical character image and a theoretical character stroke corresponding to a first training character, and a mask character stroke that masks part of the theoretical character stroke,
- inputting, for the plurality of first training samples, a theoretical character image and a mask character stroke in a current first training sample into a to-be-trained font feature extraction sub-model to obtain an actual character image and a predicted character stroke corresponding to the current first training sample,
- conducting loss processing on the actual character image and the theoretical character image on the basis of a first preset loss function in the to-be-trained feature extraction sub-model, and conducting loss processing on the predicted character stroke and the theoretical character stroke on the basis of a second preset loss function to correct a model parameter in the to-be-trained font feature extraction sub-model according to a plurality of loss values obtained,
- setting convergence of the first preset loss function and the second preset loss function as a training target to obtain a to-be-used font feature extraction sub-model, and
- conducting eliminating processing on the to-be-used font feature extraction sub-model to obtain the first and second font feature extraction sub-models.
Dependencies are inferred from the claim text.