Text synthesis method, apparatus, and electronic device
By combining a candidate background library and a handwritten text library, the problem of uncontrollable handwritten text synthesis style in existing technologies is solved, achieving high-quality text synthesis effects.
Patent Information
- Application Number
- CN202210162223.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-02-22
- Publication Date
- 2026-03-03
- Estimated Expiration
- 2042-02-22
AI Technical Summary
Existing methods for synthesizing handwritten text have difficulty controlling the style of the synthesized text, resulting in poor final synthesized text quality.
A candidate background library is generated by acquiring handwritten style images and a text erasure model. A handwritten text library is generated by combining the text to be transferred and feature vectors with a text synthesis model. The background images and handwritten text images are then fused using a Poisson fusion algorithm to control the style of the text content.
It achieves effective control over text style, improves the quality of fused images, and ensures the effectiveness of background images and the variability of text content.
Smart Images

Figure CN114549698B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of text processing, and specifically provides a text synthesis method, apparatus, and electronic device. Background Technology
[0002] Currently, traditional methods for synthesizing handwritten text include methods using handwritten font libraries and methods using individual handwritten character sets for splicing. First, the method using handwritten font libraries, similar to printed text, can quickly synthesize a large number of samples, but it is limited by the inherent limitations of the font library itself, making it impossible to control the writing style. Second, the method using individual handwritten character sets can solve the problem of monotonous character shapes in the font library method, producing a more cursive writing style. However, this method first requires collecting a base library of individual handwritten characters, which often incurs significant time and financial costs. Furthermore, the text style generated by this method is uncontrollable, resulting in a poor final synthesized text quality.
[0003] Accordingly, there is a need in this field for a new text synthesis scheme to solve the above problems. Summary of the Invention
[0004] To overcome the aforementioned shortcomings, this invention is proposed to provide a solution, or at least a partial solution, to the technical problem that existing handwritten text synthesis methods struggle to control the style of the synthesized text, resulting in poor final synthesized text quality. This invention provides a text synthesis method, apparatus, and electronic device.
[0005] In a first aspect, the present invention provides a text synthesis method, characterized by comprising the following steps: acquiring a handwritten style image, text to be transferred, and a feature vector providing style information; determining a candidate background library based on the handwritten style image and a text erasure model; determining a handwritten text library based on the text to be transferred, the feature vector, and the text synthesis model; acquiring a background image and a handwritten synthesized text image from the candidate background library and the handwritten text library, respectively; and fusing the background image and the handwritten synthesized text image to obtain a fused image.
[0006] In one embodiment, determining a candidate background library based on the handwritten style image and the text erasure model includes: dividing the handwritten style image into multiple handwritten slices; sequentially inputting the multiple handwritten slices into the text erasure model to obtain an initial background library; and preprocessing the initial background library to obtain a candidate background library.
[0007] In one embodiment, preprocessing the initial background library to obtain a candidate background library includes: determining whether each background image in the initial background library contains characters based on a pre-recognition model; if the background image does not contain characters, obtaining a candidate background library based on the background images that do not contain characters; if the background image contains characters, performing a filtering operation on the background images that contain characters to obtain a candidate background library.
[0008] In one embodiment, when the background image contains characters, filtering the background image containing characters to obtain a candidate background library includes: normalizing the background image containing characters to obtain a normalized background image; calculating the average width occupied by each character in the normalized background image; determining a width threshold based on the average width occupied by each character in the normalized background image; and obtaining a candidate background library based on the normalized background image when the average width occupied by each character in the normalized background image is greater than the width threshold.
[0009] In one embodiment, determining the width threshold based on the average width occupied by each character in the normalized background image includes: determining the average value and median value of all characters in the normalized background image based on the average width occupied by each character; if the average value is less than the median value, using the average value as the width threshold; if the average value is not less than the median value, using the median value as the width threshold.
[0010] In one embodiment, the text synthesis model includes a generator, a discriminator, and a recognizer, wherein the recognizer includes a CRNN network; determining the handwritten text library based on the text to be transferred, the feature vector, and the text synthesis model includes: inputting the text to be transferred and the feature vector into the text synthesis model to obtain a handwritten synthesized text image; and obtaining the handwritten text library based on the handwritten synthesized text image.
[0011] In one embodiment, fusing the background image and the handwritten synthesized text image includes: fusing the background image and the handwritten synthesized text image based on the Poisson fusion algorithm to obtain a fused image.
[0012] In a second aspect, the present invention provides a text synthesis apparatus, comprising: a first acquisition module configured to acquire a handwritten style image, text to be transferred, and a feature vector providing style information; a first determination module configured to determine a candidate background library based on the handwritten style image and a text erasure model; a second determination module configured to determine a handwritten text library based on the text to be transferred, the feature vector, and the text synthesis model; a second acquisition module configured to acquire a background image and a handwritten synthesized text image from the candidate background library and the handwritten text library, respectively; and a fusion module configured to fuse the background image and the handwritten synthesized text image to obtain a fused image.
[0013] In a third aspect, an electronic device is provided, comprising a processor and a storage device adapted to store a plurality of program codes adapted to be loaded and executed by the processor to perform the text synthesis method described in any of the preceding claims.
[0014] In a fourth aspect, a computer-readable storage medium is provided, wherein a plurality of program codes are stored therein, the program codes being adapted to be loaded and run by a processor to perform the text synthesis method described in any of the preceding claims.
[0015] The above-described technical solutions of the present invention have at least one or more of the following beneficial effects:
[0016] The text synthesis method in this invention first obtains a candidate background library containing high-quality background images based on the acquired handwritten style images and text erasure model. Then, based on the text to be transferred, feature vectors, and text synthesis model, a handwritten text library containing handwritten synthesized text images with varying styles is generated. Next, a background image and a handwritten synthesized text image are extracted from the candidate background library and the handwritten text library respectively and fused to obtain a fused image. This achieves the effect of controlling the style of text content using feature vectors and text synthesis model, thereby improving the quality of the fused image.
[0017] Based on the initial background library obtained by the text erasure model, this application further preprocesses the initial background library by determining whether it contains text and by judging the average width value of each character. This removes the interference of impurities outside the image background, further ensuring the effectiveness of the background image and improving the quality of the final candidate background library. Attached Figure Description
[0018] The disclosure of this invention will become more readily understood with reference to the accompanying drawings. It will be readily understood by those skilled in the art that these drawings are for illustrative purposes only and are not intended to limit the scope of protection of this invention. Furthermore, similar numbers in the drawings are used to denote similar components, wherein:
[0019] Figure 1 This is a schematic diagram of the main steps of a text synthesis method according to an embodiment of the present invention;
[0020] Figure 2 This is a schematic diagram of a process for preprocessing an initial background library according to an embodiment of the present invention;
[0021] Figure 3 This is a schematic diagram of the structure for generating handwritten synthesized text images using a text synthesis model according to an embodiment of the present invention;
[0022] Figure 4 This is an overall flowchart of a text synthesis method according to an embodiment of the present invention;
[0023] Figure 5 This is a schematic diagram of the main structure of a text synthesis device according to an embodiment of the present invention.
[0024] List of reference numerals :
[0025] 11: First acquisition module; 12: First determination module; 13: Second determination module; 14: Second acquisition module; 15: Fusion module. Detailed Implementation
[0026] Some embodiments of the present invention will now be described with reference to the accompanying drawings. Those skilled in the art should understand that these embodiments are merely illustrative of the technical principles of the present invention and are not intended to limit the scope of protection of the present invention.
[0027] In the description of this invention, "module" and "processor" can include hardware, software, or a combination of both. A module can include hardware circuitry, various suitable sensors, communication ports, memory, and may also include software components, such as program code, or a combination of software and hardware. A processor can be a central processing unit, microprocessor, image processor, digital signal processor, or any other suitable processor. The processor has data and / or signal processing capabilities. The processor can be implemented in software, in hardware, or a combination of both. Non-transitory computer-readable storage media includes any suitable medium capable of storing program code, such as magnetic disks, hard disks, optical disks, flash memory, read-only memory, random access memory, etc. The term "A and / or B" means all possible combinations of A and B, such as only A, only B, or A and B. The terms "at least one A or B" or "at least one of A and B" have a similar meaning to "A and / or B" and can include only A, only B, or A and B. The singular terms "a" or "this" can also include plural forms.
[0028] Here we will first explain some of the terms involved in this invention.
[0029] GAN (Generative Adversarial Networks) is an implicit generative model consisting of a generator and a discriminator. The two interact and are trained alternately until they reach equilibrium.
[0030] CRNN (Convolutional Recurrent Neural Network for Image-Based Sequence Recognition) is a classic algorithm for OCR text recognition in recent years. It is based on a segmentation-free algorithm. First, a CNN network is used to extract basic image features, then an RNN structure is used to capture temporal information, and finally, the CTC loss function is introduced to solve the label alignment problem.
[0031] Poisson image fusion: Image synthesis is a fundamental problem in image processing. Its main principle is to embed a portion of the original image into a target image while maintaining the integrity of the boundaries as much as possible. When the background textures of the source and target images differ significantly, the fusion may not appear natural. The Poisson equation primarily works at the gradient level, maintaining the consistency between the gradients of the source and target images, thereby ensuring the integrity of the boundaries.
[0032] Current traditional methods for synthesizing handwritten text struggle to control the style of the synthesized text, resulting in poor final quality. To address this, this application provides a text synthesis method, apparatus, and electronic device. First, based on acquired handwritten style images and a text erasure model, a candidate background library containing high-quality background images is obtained. Next, based on the text to be transferred, feature vectors, and a text synthesis model, a handwritten text library containing handwritten synthesized text images with diverse styles is generated. Then, a background image and a handwritten synthesized text image are extracted from the candidate background library and the handwritten text library respectively and fused to obtain a fused image. This achieves the effect of controlling the style of the text content using feature vectors and a text synthesis model, improving the quality of the fused image.
[0033] See appendix Figure 1 , Figure 1 This is a schematic flowchart illustrating the main steps of a handwritten text synthesis method according to an embodiment of the present invention. Figure 1 As shown, the text synthesis method in this embodiment of the invention mainly includes the following steps S101-S105.
[0034] Step S101: Obtain the handwriting style image, the text to be transferred, and the feature vector providing style information. Specifically, the handwriting style image is an image containing both text content and background. The text to be transferred contains only the text content. The feature vector providing style information can be a random vector with a Gaussian or uniform distribution, which is used in the text synthesis model to convolve with the convolution kernel corresponding to the text to be transferred, thereby controlling the text style of the text to be transferred.
[0035] Step S102: Determine the candidate background library based on the handwritten style image and text erasure model. The text erasure model in this application is a GAN-based text erasure model.
[0036] GANs mainly consist of a generator (G) and a discriminator (D). The generator, given a real handwritten style image x and a corresponding textless background image z, attempts to obtain a predicted textless background image y. We want the data distribution of y to be as close as possible to the data distribution of z, i.e., solving the following optimization problem:
[0037]
[0038] The generator and discriminator in this application can be existing networks. For example, the generator G can be a network architecture similar to U-Net to fuse low-level localization features and high-level visual features. The discriminator D can be a DCGAN network to reduce the dimensionality of the input features and finally determine whether they are 0 or 1 using a sigmoid function.
[0039] To further constrain the randomness of the generated images, improve image quality, and better conform to the visual characteristics of the human eye, this application adopts the loss function L shown below. total α and β are the balance factors of the loss function:
[0040] L total =L gan +αL1+βL vgg
[0041] The three loss definitions are as follows:
[0042] L gan =E (x,z) [logD(x,z)]+E (x) [log(1-D(x,y))]
[0043] L1=||zy||1
[0044] L vgg =γL per +εL style
[0045] And L vgg Perceived loss consists of two parts: content loss L per and style loss L style The definitions are as follows:
[0046]
[0047]
[0048] Where, φ i M is the activation feature map of the intermediate layer of the pre-trained model VGG-19. i Let G be the size of the feature map of the i-th layer, and G be the Gram matrix. γ and ε are the balancing factors between text content loss and style loss, respectively.
[0049] In the step of determining the candidate background library, the handwritten style image is first divided into multiple handwritten slices, then the multiple handwritten slices are sequentially input into the text erasure model to obtain the initial background library, and finally the initial background library is preprocessed to obtain the candidate background library.
[0050] During the preprocessing of the initial background library, such as Figure 2 As shown, the process first involves using a pre-recognition model to determine whether each background image in the initial background library contains characters. If the background image does not contain characters, a candidate background library is obtained based on these images; that is, the set of background images without characters is directly output as the candidate background library. If the background image contains characters, a filtering operation is performed on the background images containing characters to obtain the candidate background library. The pre-recognition model here can be a CRNN network, commonly used in text recognition.
[0051] Specifically, in the filtering process of a background image containing characters, the background image containing characters can first be normalized. Normalization is the process of normalizing the background image to a pixel value of 1 to obtain a normalized background image. Next, the average width occupied by each character in the normalized background image is calculated. For example, when 10 characters are identified in the background image, the previous steps have already normalized the background image, meaning the pixel value of the background image is 1. Then, 1 / 10 = 0.1, which is the average width occupied by each character in the background image. Next, a width threshold is determined based on the average width occupied by each character in the normalized background image. Specifically, the average and median values of all characters in the normalized background image are determined based on the average width occupied by each character. If the average value is less than the median value, the average value is used as the width threshold; if the average value is not less than the median value, the median value is used as the width threshold. Finally, it is determined whether the average width occupied by each character in the normalized background image is greater than the width threshold. If the average width occupied by each character in the normalized background image is greater than the width threshold, a candidate background library is obtained based on the normalized background image. Specifically, the set of all normalized background images that meet the aforementioned average width judgment condition is used as the candidate background library.
[0052] Based on the initial background library obtained by the text erasure model, this application further preprocesses the initial background library by determining whether it contains text and by judging the average width value of each character. This removes the interference of impurities outside the image background, further ensuring the effectiveness of the background image and improving the quality of the final candidate background library.
[0053] Step S103: Determine the handwritten text library based on the text to be transferred, feature vectors, and text synthesis model. In this step, the text to be transferred and feature vectors are first input into the text synthesis model to obtain handwritten synthesized text images. Since the feature vectors are random vectors with Gaussian or uniform distribution, multiple feature vectors can correspond to multiple handwritten synthesized text images. Finally, the set of multiple handwritten synthesized text images is used as the handwritten text library.
[0054] Specifically, such as Figure 3As shown, the text synthesis model of this application includes a generator G, a discriminator D, and a recognizer R. The generator G and discriminator D constitute the two parts of a generative adversarial network (GAN), and the recognizer can be implemented using a CRNN network. For example, for the input text "sleep", the generator first obtains the convolutional kernel corresponding to each character from a convolutional kernel library. Here, the five characters in "sleep" correspond to convolutional kernels [fs, fl, fe, fe, fp]. The generator G convolves the convolutional kernels with feature vectors providing style information to obtain the output result. The feature vectors providing style information are used to control the style of the text to be transferred. The receptive fields of the convolutional kernels overlap, which can simulate the overlapping of adjacent characters, similar to the cursive strokes of handwriting. Since each character corresponds to a convolutional kernel, the generated text is very flexible, allowing control over the size and type of the text, and the text synthesis model can learn the dependencies between characters. In the text synthesis model, the discriminator D distinguishes between generated fake and real images, while the recognizer R identifies individual characters in the generated text. They work together with the discriminator D to train the entire text synthesis model. The loss function L of the text synthesis model is... total It can be represented as:
[0055] L total =L D +αL R
[0056] Among them, L D It is the loss of the discriminator, L R α is the loss of the recognizer, and α is the weight parameter of the recognizer, which is adjusted and determined during the training process.
[0057] The handwritten text synthesis module of this application can obtain the convolution kernel of a single character, flexibly control the amplitude of the generated text, support text synthesis of arbitrary length, and the feature vector can control the writing style of the handwritten text, ultimately generating a variety of handwritten synthesized text images.
[0058] Step S104: Obtain a background image from the candidate background library and a handwritten composite text image from the handwritten text library. Specifically, in this step, a background image can be randomly selected from the candidate background library and a handwritten composite text image can be randomly selected from the handwritten text library.
[0059] Step S105: Fuse the background image and the handwritten text image to obtain a fused image. Specifically, this application uses the Poisson fusion algorithm built into OpenCV to fuse the background image and the handwritten text image to obtain a fused image. However, it is not limited to this. Traditional fusion algorithms and deep learning-based algorithms can also achieve the fusion of the background image and the handwritten text image in this application, and are all included in the protection scope of this application.
[0060] like Figure 4 The flowchart of the text synthesis method shown shows that a candidate background library can be generated based on the text erasure model, and a handwritten text library can be generated based on the text synthesis model. Then, an image is randomly selected from the candidate background library and the handwritten text library respectively, and the two are fused using the Poisson fusion algorithm to obtain a high-quality fused image.
[0061] Based on the above steps S101-S105, firstly, a candidate background library containing high-quality background images is obtained based on the acquired handwritten style images and text erasure model. Then, a handwritten text library containing handwritten synthesized text images with varying styles is generated based on the text to be transferred, feature vectors, and text synthesis model. Next, a background image and a handwritten synthesized text image are extracted from the candidate background library and the handwritten text library respectively and fused to obtain a fused image. This realizes the use of feature vectors and text synthesis model to control the style of text content and improves the quality of the fused image.
[0062] It should be noted that although the steps in the above embodiments are described in a specific order, those skilled in the art will understand that in order to achieve the effects of the present invention, different steps do not necessarily have to be executed in such an order. They can be executed simultaneously (in parallel) or in other orders, and these variations are all within the scope of protection of the present invention.
[0063] Furthermore, the present invention also provides a text synthesis apparatus. (See appendix) Figure 5 , Figure 5 This is a main structural block diagram of a text synthesis device according to an embodiment of the present invention. Figure 5As shown, the text synthesis device in this embodiment of the invention mainly includes a first acquisition module 11, a first determination module 12, a second determination module 13, a second acquisition module 14, and a fusion module 15. In some embodiments, one or more of the first acquisition module 11, the first determination module 12, the second determination module 13, the second acquisition module 14, and the fusion module 15 can be combined into a single module. In some embodiments, the first acquisition module 11 can be configured to acquire a handwritten style image, the text to be transferred, and a feature vector providing style information. The first determination module 12 can be configured to determine a candidate background library based on the handwritten style image and a text erasure model. The second determination module 13 is configured to determine a handwritten text library based on the text to be transferred, the feature vector, and the text synthesis model. The second acquisition module 14 can be configured to acquire a background image and a handwritten synthesized text image from the candidate background library and the handwritten text library, respectively. The fusion module 15 can be configured to fuse the background image and the handwritten synthesized text image to obtain a fused image. In one embodiment, a description of the specific functions can be found in steps S101-S105.
[0064] The above-mentioned text synthesis device is used to perform Figure 1 The text synthesis method embodiments shown are similar in technical principle, the technical problems solved and the technical effects produced. Those skilled in the art can clearly understand that, for the sake of convenience and brevity, the specific working process and related descriptions of the text synthesis device can be referred to the content described in the embodiments of the text synthesis method, and will not be repeated here.
[0065] Those skilled in the art will understand that all or part of the processes in the method of the above embodiment of the present invention can also be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable file, or some intermediate form. The computer-readable storage medium can include any entity or device capable of carrying the computer program code, a medium, a USB flash drive, a portable hard drive, a magnetic disk, an optical disk, a computer memory, a read-only memory, a random access memory, an electrical carrier signal, a telecommunication signal, and a software distribution medium, etc. It should be noted that the content included in the computer-readable storage medium can be appropriately added or removed according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, the computer-readable storage medium does not include electrical carrier signals and telecommunication signals.
[0066] Furthermore, the present invention also provides an electronic device. In one embodiment of the electronic device according to the present invention, the electronic device includes a processor and a storage device. The storage device can be configured to store a program for executing the text synthesis method of the above-described method embodiments, and the processor can be configured to execute the program in the storage device. The program includes, but is not limited to, the program for executing the text synthesis method of the above-described method embodiments. For ease of explanation, only the parts related to the embodiments of the present invention are shown. For specific technical details not disclosed, please refer to the method section of the embodiments of the present invention.
[0067] Furthermore, the present invention also provides a computer-readable storage medium. In one embodiment of the computer-readable storage medium according to the present invention, the computer-readable storage medium can be configured to store a program that performs the text synthesis method of the above-described method embodiments. This program can be loaded and run by a processor to implement the above-described text synthesis method. For ease of explanation, only the parts related to the embodiments of the present invention are shown; for specific technical details not disclosed, please refer to the method section of the embodiments of the present invention. The computer-readable storage medium can be a storage device comprising various electronic devices. Optionally, in the embodiments of the present invention, the computer-readable storage medium is a non-transitory computer-readable storage medium.
[0068] Furthermore, it should be understood that since the various modules are only provided to illustrate the functional units of the device of the present invention, the physical devices corresponding to these modules may be the processor itself, or a part of the processor's software, hardware, or a combination of software and hardware. Therefore, the number of modules shown in the figures is merely illustrative.
[0069] Those skilled in the art will understand that the various modules in the device can be adaptively split or combined. Such splitting or combining of specific modules will not cause the technical solution to deviate from the principles of the present invention; therefore, the technical solutions after splitting or combining will fall within the protection scope of the present invention.
[0070] The technical solution of the present invention has been described above with reference to the preferred embodiments shown in the accompanying drawings. However, it will be readily understood by those skilled in the art that the scope of protection of the present invention is obviously not limited to these specific embodiments. Without departing from the principles of the present invention, those skilled in the art can make equivalent changes or substitutions to the relevant technical features, and the technical solutions after such changes or substitutions will all fall within the scope of protection of the present invention.
Claims
1. A text synthesis method characterized by, The method comprises the following steps: obtaining a handwriting style image, a text to be migrated, and a feature vector providing style information; determining a candidate background library based on the handwriting style image and a text erasing model; determining a handwriting text library based on the text to be migrated, the feature vector, and a text synthesis model, comprising: inputting the text to be migrated and the feature vector into the text synthesis model to obtain a handwriting synthesis text image; and obtaining a handwriting text library based on the handwriting synthesis text image, wherein the feature vector providing style information is a random vector adopting a Gaussian distribution or a uniform distribution, and is used for convolution with a convolution kernel corresponding to the text to be migrated in the text synthesis model to control the text style of the text to be migrated; obtaining a background image and a handwriting synthesis text image from the candidate background library and the handwriting text library respectively; fusing the background image and the handwriting synthesis text image to obtain a fused image.
2. The text synthesis method according to claim 1, characterized by, The method comprises the following steps: dividing the handwriting style image into a plurality of handwriting slices; inputting the plurality of handwriting slices into the text erasing model in sequence to obtain an initial background library; preprocessing the initial background library to obtain a candidate background library.
3. The text synthesis method according to claim 2, characterized by, The method comprises the following steps: judging whether each background image in the initial background library contains characters based on a pre-recognition model; in the case that the background image does not contain characters, obtaining a candidate background library based on the background image not containing characters; in the case that the background image contains characters, performing a filtering operation on the background image containing characters to obtain a candidate background library.
4. The text synthesis method according to claim 3, characterized by, The method comprises the following steps: performing a normalization operation on the background image containing characters to obtain a normalized background image; calculating the average width occupied by each character in the normalized background image; determining a width threshold based on the average width occupied by each character in the normalized background image; in the case that the average width occupied by each character in the normalized background image is greater than the width threshold, obtaining a candidate background library based on the normalized background image.
5. The text synthesis method according to claim 4, characterized by, The method comprises the following steps: determining the average value and the median value of all characters in the normalized background image based on the average width occupied by each character respectively; in the case that the average value is less than the median value, taking the average value as the width threshold, and in the case that the average value is not less than the median value, taking the median value as the width threshold.
6. The text synthesis method of claim 1, wherein, The text synthesis model comprises a generator, a discriminator, and an identifier, and the identifier comprises a CRNN network.
7. The text synthesis method of claim 1, wherein, The method comprises the following steps:
8. A text synthesizing apparatus characterized by comprising: fusing the background image and the handwriting synthesis text image based on a Poisson fusion algorithm to obtain a fused image. The method comprises the following steps: a first obtaining module configured to obtain a handwriting style image, a text to be migrated, and a feature vector providing style information; The first determining module is configured to determine a candidate background library based on the handwriting style image and a text erasing model. The second determining module is configured to determine a handwriting text library based on the text to be migrated, the feature vector, and a text synthesis model, including: inputting the text to be migrated and the feature vector into the text synthesis model to obtain a handwriting synthetic text image; and obtaining a handwriting text library based on the handwriting synthetic text image, wherein the feature vector providing style information is a random vector adopting a Gaussian distribution or a uniform distribution, and is used to control the text style of the text to be migrated by performing convolution on a convolution kernel corresponding to the text to be migrated in the text synthesis model. The second obtaining module is configured to obtain a background image and a handwriting synthetic text image from the candidate background library and the handwriting text library, respectively. The fusion module is configured to fuse the background image and the handwriting synthetic text image to obtain a fusion image.
9. An electronic device comprising a processor and a storage device, said storage device being adapted to store a plurality of program codes, characterized in that, The program code is adapted to be loaded and run by the processor to execute the text synthesis method in any one of claims 1 to 7.
10. A computer readable storage medium having stored therein a plurality of program codes, characterized in that, The program code is adapted to be loaded and run by the processor to execute the text synthesis method in any one of claims 1 to 7.