Text image generation method and device, electronic equipment and storage medium
By acquiring text image generation requests, performing contour extraction and extended text determination, and combining deep learning models to generate text images, the problem of difficulty in simultaneously ensuring readability and creativity in text image generation in existing technologies is solved, and high-quality text image generation is achieved.
Patent Information
- Application Number
- CN202310744636.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-21
- Publication Date
- 2026-11-20
- Estimated Expiration
- 2043-06-21
AI Technical Summary
Existing technologies struggle to efficiently generate high-quality, highly creative text images, especially during text-to-image conversion, where it is difficult to simultaneously ensure both text readability and content richness.
By acquiring text image generation requests, contour extraction and extended text determination are performed. The text image is generated by combining a text-conditional latent diffusion generation model and a controllable diffusion generation encoder. The contour map and extended text features are then fused to generate an artistic image.
It improves the readability and content richness of the generated text and images, enhances creativity, meets the needs of different application scenarios, and optimizes the user experience.
Smart Images

Figure CN116821363B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of artificial intelligence technology, particularly to the fields of computer vision, knowledge graphs, and deep learning, and specifically to a method, apparatus, electronic device, and storage medium for generating text images. Background Technology
[0002] In recent years, AI-Generated Content (AIGC) technology has developed rapidly, significantly improving the quality and efficiency of content production. Among these technologies, text-to-image generation has received particularly widespread attention and application. This technology can automatically generate professional-level, exquisite paintings from simple text descriptions, making it highly valuable in many situations. Therefore, finding a highly efficient and high-quality image generation method is currently an urgent problem to be solved. Summary of the Invention
[0003] This disclosure provides a method, apparatus, electronic device, and storage medium for generating text images.
[0004] According to a first aspect of this disclosure, a method for generating text images is provided, comprising:
[0005] Obtain a text image generation request, wherein the generation request includes source text;
[0006] The source text is extracted to obtain the contour image corresponding to the source text;
[0007] Determine the extended text corresponding to the source text;
[0008] Based on the extended text and the outline image, a text image corresponding to the source text is generated.
[0009] According to a second aspect of this disclosure, an apparatus for generating text images is provided, comprising:
[0010] The first acquisition module is used to acquire a text image generation request, wherein the generation request includes source text;
[0011] The second acquisition module is used to extract the outline of the source text and obtain the outline image corresponding to the source text;
[0012] The first determining module is used to determine the extended text corresponding to the source text;
[0013] The first generation module is used to generate a text image corresponding to the source text based on the extended text and the outline map.
[0014] According to a third aspect of this disclosure, an electronic device is provided, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to perform the text image generation method described in the first aspect of this disclosure.
[0015] According to a fourth aspect of this disclosure, a non-transitory computer-readable storage medium storing computer instructions for causing a computer to execute the text image generation method described in the first aspect of this disclosure is proposed.
[0016] According to a fifth aspect of this disclosure, a computer program product is proposed, comprising a computer program that, when executed by a processor, implements the method for generating text images as described in the first aspect of this disclosure.
[0017] The method, apparatus, electronic device, and storage medium for generating text images disclosed herein have the following beneficial effects:
[0018] In this embodiment of the disclosure, after receiving a text image generation request, the text image generation system first extracts the contours of the source text contained in the generation request to obtain the contour map corresponding to the source text. Then, it determines the extended text corresponding to the source text, and finally generates the text image corresponding to the source text based on the extended text and the contour map. Thus, by generating text images based on the contour map and extended text corresponding to the source text, the readability of the generated image is ensured, while also improving the richness and creativity of the generated text image's content.
[0019] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of this disclosure, nor is it intended to limit the scope of this disclosure. Other features of this disclosure will become readily apparent from the following description. Attached Figure Description
[0020] The accompanying drawings are provided to better understand this solution and do not constitute a limitation of this disclosure. Wherein:
[0021] Figure 1 This is a schematic flowchart of a method for generating text images according to an embodiment of the present disclosure;
[0022] Figure 2 This is a schematic flowchart of a method for generating text images according to another embodiment of this disclosure;
[0023] Figure 3 This is a schematic flowchart of a method for generating text images according to another embodiment of this disclosure;
[0024] Figure 4This is a schematic flowchart of a method for generating text images according to another embodiment of this disclosure;
[0025] Figure 5 This is a schematic flowchart of a method for generating text images according to another embodiment of this disclosure;
[0026] Figure 6 This is a schematic flowchart of a method for generating text images according to another embodiment of this disclosure;
[0027] Figure 7 This is a schematic diagram of the structure of a text image generation apparatus according to an embodiment of the present disclosure;
[0028] Figure 8 This is a schematic block diagram of an electronic device used to implement the text image generation method of the embodiments of this disclosure. Detailed Implementation
[0029] The exemplary embodiments of this disclosure are described below with reference to the accompanying drawings, including various details of the embodiments to aid understanding, and should be considered merely exemplary. Therefore, those skilled in the art will recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of this disclosure. Similarly, for clarity and brevity, descriptions of well-known functions and structures are omitted in the following description.
[0030] This disclosure relates to the field of artificial intelligence technology, specifically to the fields of computer vision, knowledge graphs, and deep learning.
[0031] Artificial Intelligence (AI) is a new technological science that studies and develops theories, methods, technologies, and application systems for simulating, extending, and expanding human intelligence.
[0032] Computer vision refers to machine vision that uses cameras and computers to identify, track, and measure targets instead of human eyes, and further processes the images to make them more suitable for human observation or transmission to instruments for detection.
[0033] Knowledge graphs are a structured and semantic representation used to describe the relationships between entities, concepts, and things. Based on semantic data structures, they support automatic reasoning and intelligent querying, and can perform in-depth mining and analysis of knowledge.
[0034] Deep learning learns the inherent patterns and hierarchical representations of sample data. The information gained during this learning process greatly aids in interpreting data such as text, images, and sound. The ultimate goal of deep learning is to enable machines to possess analytical and learning capabilities similar to humans, allowing them to recognize data such as text, images, and sound.
[0035] The acquisition, storage, and application of user personal information involved in the technical solution disclosed herein comply with the provisions of relevant laws and regulations and do not violate public order and good morals.
[0036] The following description, with reference to the accompanying drawings, describes a method, apparatus, electronic device, and storage medium for generating text images according to embodiments of the present disclosure.
[0037] It should be noted that the execution subject of the text image generation method in this embodiment is a text image generation device, which can be implemented by software and / or hardware. The device can be configured in an electronic device, which may include, but is not limited to, a terminal, a server, etc.
[0038] Figure 1 This is a schematic flowchart of a method for generating text images according to an embodiment of the present disclosure.
[0039] like Figure 1 As shown, the method for generating the text image includes:
[0040] S101: Obtain a text image generation request, wherein the generation request includes the source text.
[0041] In this disclosure, the text image can be an artistic font image, which is a font image whose main purpose is to beautify the form of text, and can have both creativity and text readability.
[0042] In this context, source text refers to the original text input by the user used to generate the image. The number of source texts can be single or multiple, and the form of the source texts can also be diverse. For example, the source texts may be Chinese or English, etc. This disclosure does not limit this.
[0043] In this embodiment of the disclosure, the user can input the source text to be generated into the text image in the operation interface of the text image generation system, and after clicking the image generation control in the operation interface, the text image generation system can obtain the text image generation request. Alternatively, the text image generation function can be triggered during the use of the application, thereby sending a text image generation request to the text image generation system. Alternatively, the user can also input a first image containing the source text in the operation interface of the text image generation system, and after clicking the image generation control in the operation interface, the text image generation system can obtain the source text from the obtained first image. This disclosure does not limit this aspect.
[0044] S102: Extract the outline of the source text to obtain the outline image corresponding to the source text.
[0045] Contour extraction can be achieved through edge extraction operators, such as cv2, Canny, etc., and this disclosure does not limit it.
[0046] In some possible implementations, if the generation request includes a first image containing the source text, the contour of the source text in the first image can be extracted to obtain the contour map corresponding to the source text. Alternatively, if the generation request does not include a first image containing the source text, the font contour corresponding to the source text in the font library can be rendered to generate a second image corresponding to the source text, and then the contour of the second image can be extracted to obtain the contour map corresponding to the source text.
[0047] The font library may be pre-installed in the text image generation system and may contain font outlines corresponding to each character. In this disclosure, the font outlines can be rendered based on the required font style, which may be KaiTi, SongTi, LiShu, etc., and this disclosure does not limit this.
[0048] In this embodiment of the disclosure, when the generation request includes a first image containing the source text, the outline of the source text in the first image can be directly extracted, thereby improving the efficiency of outline extraction. Alternatively, when the generation request does not include the first image, the font style of the source text can be determined first, then the font outline corresponding to the source text can be obtained from the font library, and then a second image can be determined based on the determined font style. After that, the outline of the second image can be extracted to obtain the outline image corresponding to the source text, thereby providing conditions for improving the diversity of generated text images.
[0049] In some possible implementations, the generation request may include a font style. In this case, the text image generation system can render the font outline corresponding to the source text based on the font style in the generation request, generating a second image corresponding to the source text. Alternatively, if the generation request does not include a font style, the text image generation system can still render the font outline based on a preset font style, generating a second image corresponding to the source text. This approach of rendering based on font styles to obtain the image corresponding to the source text increases the diversity of fonts in the generated text images.
[0050] The preset font style can be fixed or can be adapted to change according to the generation request.
[0051] In some possible implementations, a preset font style can be determined based on the type of the target text image to be generated.
[0052] The type of the target text image can be determined based on the application scenario of the text image to be generated. For example, when the text image to be generated is used for pictographic Chinese character education and enlightenment, the type of the target text image can be a pictographic character image; or when the text image to be generated is used for signature, the type of the target text image can be an artistic character signature image, and so on.
[0053] For example, when the target text image is a pictographic image, oracle bone script can be used as the default font style. Or, when the target text image is an artistic signature image, cursive script or other similar scripts can be used as the default font style, and so on. This disclosure does not limit this.
[0054] Alternatively, the preset font style can be determined based on the type of service that triggered the request.
[0055] The service that triggers the generation request is the service that sends the generation request to the text image generation system. For example, it may be a chat service or an artistic font signature application, etc. This disclosure does not limit it.
[0056] For example, when an artistic signature application sends a generation request, the text image generation system may use cursive or semi-cursive script as the default font style, etc., which is not limited in this disclosure.
[0057] In this embodiment of the disclosure, the font style in the text image can be determined according to the type of the target text image or the type of the service that triggers the generation request, so that the generated text image is more in line with the application requirements and the applicability of the generated text image is improved.
[0058] S103: Determine the extended text corresponding to the source text.
[0059] Extended text refers to text composed of words semantically related to the source text, which can be obtained by a text image generation system after extending the source text.
[0060] It should be noted that the number of words contained in the extended text can be determined by the user in the operation interface of the text image generation system, or it can be determined according to the type of the source text, etc. This disclosure does not limit this.
[0061] In this embodiment of the disclosure, the text image generation system can use an automatic prompt word project to take the source text as the original query statement, and rewrite and / or expand the original query by matching it with a template and calling a large-scale language model, so as to determine the extended text corresponding to the source text.
[0062] For example, when the source text is “bear”, the artistic font template can be determined by matching it with the template. Then, by calling a large-scale language model, words that are semantically related to “bear”, such as “forest”, can be determined. The extended text determined at this time can be “artistic font, bear, forest”, etc. This disclosure does not limit this.
[0063] S104: Generate text images corresponding to the source text based on the extended text and contour map.
[0064] In this embodiment of the disclosure, the extended text and the contour map can be encoded separately, and then the features of the two encoded features can be fused. After that, the fused encoding can be decoded to generate the text image corresponding to the source text.
[0065] In some possible implementations, a first encoder can be used to encode the extended text, obtaining the corresponding first feature. Then, a second encoder can be used to encode the contour map, obtaining the corresponding second feature. The first and second features are then fused to obtain a fused feature. Finally, a decoder is used to decode the fused feature to obtain the text image corresponding to the source text. By fusing the contour map of the source text with the extended text before decoding, it is possible to generate an artistic image based on the extended text while ensuring that the text in the generated image is as similar as possible to the contour of the source text, thus improving the readability of the generated image.
[0066] The first encoder and decoder can be the encoder and decoder in a text-conditional latent diffusion generative model (LDM). The second encoder can be a controllable diffusion generative encoder (Controlnet), which can be used to perform targeted optimization on the contour map and output a series of image representations of the contour map, that is, the second feature corresponding to the contour map.
[0067] In this embodiment of the disclosure, the second feature corresponding to the contour map can be input into the hidden diffusion generation model of the text condition, and weighted and fused with the first feature obtained by the first encoder in the model, and the text image of the source text can be obtained by decoding the fused feature.
[0068] In some possible implementations, the first and second features can be weighted and fused based on preset weight values to obtain a fused feature. This allows for a balance between the creativity and control over the text outline of the generated text image, further enhancing the user experience.
[0069] In different application scenarios, the preset weight values can be the same; or they can vary according to the needs of the generated image. For example, when the creativity of the generated image is highly required, the weight corresponding to the first feature can be appropriately increased; or when the readability of the text in the generated image is highly required, the weight corresponding to the second feature can be appropriately increased, etc. This disclosure does not limit this.
[0070] In some possible implementations, preset weight values can be determined based on the type of the target text image to be generated. The type of text image can include pictographic images, calligraphy works, artistic signature images, etc., and this disclosure does not limit this. In this disclosure, the weight values corresponding to the first feature and the second feature can be determined according to the degree of emphasis on creativity and text readability of the target text image type.
[0071] Alternatively, the preset weight value can be determined based on the type of service that triggers the generation request. For example, when the service that triggers the generation request is an artistic signature application, because the readability of the text image to be generated is required to be high, the weight corresponding to the first feature may be greater than the weight corresponding to the second feature, etc. This disclosure does not limit this.
[0072] Alternatively, the weight values included in the generated request can be set to preset weight values. This allows for the determination of the feature fusion strength between the extended text and the contour map according to actual application needs, improving the flexibility of text image generation.
[0073] In this embodiment, after receiving a text image generation request, the text image generation system first extracts the contours of the source text contained in the request to obtain the contour map corresponding to the source text. Then, it determines the extended text corresponding to the source text. Finally, based on the extended text and the contour map, it generates the text image corresponding to the source text. Thus, by generating text images based on the contour map and extended text corresponding to the source text, the readability of the generated image is ensured, while also improving the richness and creativity of the generated text image content.
[0074] Figure 2 This is a flowchart illustrating a method for generating text images according to yet another embodiment of this disclosure.
[0075] like Figure 2 As shown, the method for generating the text image includes:
[0076] S201: Obtain a text image generation request, wherein the generation request includes the source text.
[0077] For a detailed description of the specific implementation of S201 above, please refer to other embodiments of this disclosure, which will not be repeated here.
[0078] S202: If the request contains multiple source texts, render the outlines corresponding to each of the multiple source texts to obtain multiple rendered text images.
[0079] In this embodiment of the disclosure, the text outlines corresponding to multiple source texts in the generation request can be rendered based on the same text style, or they can be rendered based on multiple different text styles. Furthermore, the target text style may be included in the generation request; the user can specify the font style corresponding to each source text in the generation request, or it may be a preset font style determined by the type of the target text image to be generated or the type of service that triggered the generation request.
[0080] In this embodiment of the disclosure, the generation request may also include multiple first images containing source texts respectively. In this case, the first image can be used as the text image corresponding to the source text.
[0081] S203: Based on a preset arrangement, multiple text images are arranged and merged to generate a third image.
[0082] The arrangement method can be vertical, horizontal, or freely arranged, etc., and this disclosure does not limit it.
[0083] In some possible implementations, the arrangement included in the generation request can be determined as a preset arrangement. Alternatively, the preset arrangement can be determined based on the type of the target text image to be generated. This allows for the determination of a reasonable arrangement of text when there is a large amount of source text, providing a basis for improving the aesthetic appeal of the generated text image's layout.
[0084] In this embodiment of the disclosure, when a user sends a request to generate a text image, they can select the arrangement of the source text on the operation interface. Thus, the text image generation system can determine the arrangement of multiple text images corresponding to the source text after receiving the generation request. Alternatively, the text image generation system can also determine the arrangement of multiple text images based on the type of the target text image to be generated. For example, when the target text image to be generated is an artistic signature image, due to the writing and reading habits of signatures, a horizontal arrangement can be used as the preset arrangement, etc. This disclosure does not limit this aspect.
[0085] In this embodiment of the disclosure, after arranging multiple text images, the distance between each text image can be adjusted to improve the visual harmony of the generated text images. Overlapping areas between text images can be merged. For example, the front-to-back relationship of the images can be determined, and the overlapping parts of the later images can be deleted, or the strokes of the overlapping areas can be merged, etc. This disclosure does not limit this, and then a third image corresponding to multiple source texts can be obtained.
[0086] S204: Extract contours from the third image to obtain contour images corresponding to multiple source characters.
[0087] S205: Determine the extended text corresponding to the source text.
[0088] S206: Generate a text image corresponding to the source text based on the extended text and contour map.
[0089] For specific implementations of S204-S206 above, please refer to the detailed descriptions of other embodiments of this disclosure, which will not be repeated here.
[0090] In this embodiment, after receiving a text image generation request, if the request contains multiple source characters, the system renders the outlines corresponding to each source character to obtain multiple rendered text images. Then, based on a preset arrangement, the multiple text images are arranged and merged to generate a third image. Next, the outlines of the third image are extracted to obtain the outline maps corresponding to the multiple source characters. Then, the extended text corresponding to the source characters is determined. Based on the extended text and the outline maps, the text image corresponding to the source characters is generated. Therefore, multiple source characters can be arranged in any form to generate corresponding text images, improving the flexibility and diversity of the generated text images and further optimizing the user experience.
[0091] Figure 3 This is a flowchart illustrating a method for generating text images according to yet another embodiment of this disclosure.
[0092] like Figure 3 As shown, the method for generating the text image includes:
[0093] S301: Acquire a text image generation request, wherein the generation request includes source text.
[0094] S302: Perform contour extraction on the source text to obtain a contour map corresponding to the source text.
[0095] For the specific implementation forms of the above S301 to S302, reference may be made to the detailed descriptions of other embodiments of the present disclosure, which will not be repeated here.
[0096] S303: Determine the content acquired from the text input box as the reference text corresponding to the source text.
[0097] The text input box refers to the area for user input content in the operation interface that can send a text image generation request, which may be the information input area in a chat software interface, or the text input area in various text image generation applications, etc. The present disclosure does not limit this.
[0098] The reference text may be the source text, or a text semantically related to the source text, and the text may consist of one or more words. For example, if the source text is "mushroom", the reference text acquired in the text input box may be "mushroom", or "mushroom, red", etc. The present disclosure does not limit this.
[0099] S304: Expand the reference text based on a preset extended text template to generate an extended text corresponding to the source text.
[0100] The preset extended text template in the present disclosure refers to an artistic font template, based on which the text "artistic font" can be added to the reference text to obtain the extended text corresponding to the source text, so that the generated text image can be an artistic font image.
[0101] S305: Generate a text image corresponding to the source text based on the extended text and the contour map.
[0102] For the specific implementation form of the above S305, reference may be made to the detailed descriptions of other embodiments of the present disclosure, which will not be repeated here.
[0103] In this embodiment, after acquiring the text image generation request, the text image generation system performs contour extraction on the source text to obtain the contour map corresponding to the source text, then determines the content acquired from the text input box as the reference text corresponding to the source text, then expands the reference text based on the preset extended text template to generate the extended text corresponding to the source text, and then generates the text image corresponding to the source text based on the extended text and the contour map. Therefore, the reference text of the source text is combined with the template for expansion, which enhances the stability of the artistic font effect of the generated text image.
[0104] Figure 4 This is a flowchart illustrating a method for generating text images according to yet another embodiment of this disclosure.
[0105] like Figure 4 As shown, the method for generating the text image includes:
[0106] S401: Obtain a text image generation request, wherein the generation request includes the source text.
[0107] S402: Extract the outline of the source text to obtain the outline image corresponding to the source text.
[0108] For specific implementations of S401-S402 described above, please refer to the detailed descriptions of other embodiments of this disclosure, which will not be repeated here.
[0109] S403: Use a text generation model to generate extended text corresponding to the source text.
[0110] Among them, a text generation model refers to a model that can generate text by determining relevant words based on the semantics of the source text. It can be an existing model that is pre-set in the text and image generation system, such as a large-scale language model, etc.
[0111] In some possible implementations, the text image generation system can first generate multiple candidate texts based on the semantic similarity between the source text and each candidate text. Then, these candidate texts are displayed, and the selected candidate text is identified as the expanded text corresponding to the source text. Thus, by expanding the text based on semantic similarity, the expanded text becomes more reasonable, and by displaying the candidate texts to be determined for the user to choose from, the generated text image is ensured to meet the user's intent, thereby improving the efficiency of text image generation.
[0112] Candidate texts may be characters or words that are related to the source text, as determined by a large-scale language model. Each candidate text may include one or more candidate texts, and the candidate texts in multiple candidate texts may be completely different, or may contain some of the same candidate texts, etc. This disclosure does not limit this.
[0113] In this embodiment of the disclosure, multiple candidate texts can be generated by selecting candidate texts based on the semantic similarity between the source text and each candidate text, and the generated candidate texts can be displayed in the display interface of the text image generation system. Then, the user can determine a text that matches the target from the multiple candidate texts displayed, thereby the text image generation system determines the extended text corresponding to the source text.
[0114] In some possible implementations, different expansion modes can be configured when expanding the source text due to its different parts of speech. Therefore, the type of the source text can be determined first, followed by the target text expansion mode. Then, based on the target text expansion mode, the source text is expanded to obtain the corresponding expanded text. This allows for the acquisition of expanded text tailored to different types of source text, improving the efficiency of expanded text acquisition and making the obtained expanded text more reasonable, thus providing conditions for enhancing the innovation of the generated text images.
[0115] The type of source text can be a concrete word, such as bear or lamp, or an abstract word, such as love or happiness. This disclosure does not limit this.
[0116] The text expansion mode refers to the various ways configured in the text generation model to expand the source text. Different types of source text may correspond to different text expansion modes. Each text expansion mode may correspond to a different expansion model, or the number of words in the generated expanded text may differ, etc., which are not limited in this disclosure.
[0117] For example, if the source word "bear" is a concrete word, based on its corresponding target word expansion model, the source word can be retained, and semantically related words such as "forest" can be added to generate expanded text. Alternatively, when the source word "love" is an abstract word, based on its corresponding target word expansion model, the source word can be rewritten to obtain the word "love heart," and semantically related words can be added to generate expanded text, and so on. This disclosure does not limit this.
[0118] S404: Generate a text image corresponding to the source text based on the extended text and contour map.
[0119] For a detailed description of the specific implementation of S404 above, please refer to other embodiments of this disclosure, which will not be repeated here.
[0120] In this embodiment, after receiving a text image generation request, the text image generation system extracts the contour of the source text to obtain a contour map corresponding to the source text. Then, using a text generation model, it generates extended text corresponding to the source text. Finally, based on the extended text and the contour map, it generates a text image corresponding to the source text. Thus, by obtaining extended text through a text generation model, the generated extended text becomes more reasonable and logical, thereby providing conditions for further improving the quality of the generated text image.
[0121] Figure 5 This is a flowchart illustrating a method for generating text images according to yet another embodiment of this disclosure.
[0122] like Figure 5As shown, the method for generating the text image includes:
[0123] S501: Obtain a text image generation request, wherein the generation request includes the source text.
[0124] S502: Extract the outline of the source text to obtain the outline image corresponding to the source text.
[0125] S503: Determine the extended text corresponding to the source text.
[0126] S504: Generate a text image corresponding to the source text based on the extended text and contour map.
[0127] For specific implementations of S501-S504 described above, please refer to the detailed descriptions of other embodiments of this disclosure, which will not be repeated here.
[0128] S505: Display text and images.
[0129] In this embodiment of the disclosure, after obtaining the text image corresponding to the source text, the text image generation system can present it on the display interface to intuitively show the generation result of the text image.
[0130] S506: Upon receiving an editing instruction for a text image, display the weight value adjustment control.
[0131] In this embodiment of the disclosure, the user can edit the generated text image. When the user clicks the editing control on the interface where the text image is located, the text image generation system can receive the editing instruction for the text image. Then, the user can adjust the weights of the first feature and the second feature respectively in the weight value adjustment control on the interface based on the difference between the current text image generation effect and the target generated text image effect.
[0132] S507: Based on the received adjusted weight values, the first feature and the second feature are re-weighted and fused, and a new text image corresponding to the source text is obtained based on the new fused features.
[0133] In this embodiment, after receiving a text image generation request, the text image generation system first extracts the contour of the source text contained in the request to obtain the contour map corresponding to the source text. Then, it determines the extended text corresponding to the source text. Based on the extended text and the contour map, it generates a text image corresponding to the source text and displays the text image. Upon receiving an editing instruction for the text image, it displays a weight adjustment control and, based on the received adjusted weight value, re-weights and fuses the first and second features. A new text image corresponding to the source text is then obtained based on the newly fused features. Thus, by adjusting the weight values of the generated text image, the generated text image better meets user needs, further optimizing the user experience.
[0134] Figure 6 This is a flowchart illustrating a method for generating text images according to yet another embodiment of this disclosure.
[0135] like Figure 6 As shown, the method for generating the text image includes:
[0136] S601: Based on the first training dataset, train and obtain the first encoder and decoder, wherein the first training dataset includes text and text-image pairs.
[0137] S602: Based on the second training dataset, the first encoder and the decoder, train and obtain the second encoder, wherein each second training dataset includes text, text contour map and corresponding text image.
[0138] In this embodiment of the disclosure, the first training dataset and the second training dataset may be readily available datasets configured in the text image generation system, or they may be constructed by acquiring a large amount of data from the network.
[0139] In this disclosure, when training the second encoder, the text in the second training data can be input into the first encoder, and the text contour map can be input into the second encoder to be trained. The features output by the first encoder and the second encoder are then fused and input into the decoder to obtain the predicted text image. Finally, the second encoder is reverse-corrected based on the difference between the predicted text image and the text image contained in the second training data until the difference between the text image obtained by the first encoder, the second encoder and the decoder and the text image in the training data is less than a threshold, or the specified number of training iterations is reached.
[0140] In this disclosure, a first encoder and decoder are first trained, and then, with the first encoder and decoder fixed, a second encoder is trained using a second training dataset containing text contour maps. This not only improves the training efficiency of the model but also enhances the reliability and accuracy of the generated text image model. In this embodiment, the text image generation system trains and obtains the first encoder and decoder based on the first training dataset, and then trains and obtains the second encoder based on the second training dataset, the first encoder, and the decoder. Therefore, this not only improves the training efficiency of the model but also enhances the reliability and accuracy of the generated text image model.
[0141] like Figure 7 The text image generation device 700 includes:
[0142] The first acquisition module 701 is used to acquire a text image generation request, wherein the generation request includes the source text.
[0143] The second acquisition module 702 is used to extract the outline of the source text and obtain the outline image corresponding to the source text.
[0144] The first determining module 703 is used to determine the extended text corresponding to the source text.
[0145] The first generation module 704 is used to generate a text image corresponding to the source text based on the extended text and the outline map.
[0146] In some possible implementations, the second acquisition module 702 described above is further configured to:
[0147] If the request includes a first image containing the source text, the contour of the source text in the first image is extracted to obtain the contour map corresponding to the source text.
[0148] In some possible implementations, the second acquisition module 702 described above is further configured to:
[0149] If the first image containing the source text is not included in the generation request, the font outline corresponding to the source text in the font library is rendered to generate the second image corresponding to the source text.
[0150] Contour extraction is performed on the second image to obtain the contour map corresponding to the source text.
[0151] In some possible implementations, the second acquisition module 702 described above is further configured to:
[0152] If the request includes a font style, the font outline is rendered based on the font style to generate a second image corresponding to the source text; or...
[0153] If the font style is not included in the generation request, the font outline is rendered based on the preset font style to generate a second image corresponding to the source text.
[0154] In some possible implementations, the second acquisition module 702 described above is further configured to:
[0155] Based on the type of the target text image to be generated, determine the preset font style; or,
[0156] The preset font style is determined based on the type of service that triggered the request.
[0157] In some possible implementations, the second acquisition module 702 described above is further configured to:
[0158] When the generated request contains multiple source texts, the outlines corresponding to each of the multiple source texts are rendered to obtain multiple rendered text images.
[0159] Based on a preset arrangement, multiple text images are arranged and merged to generate a third image;
[0160] Contour extraction is performed on the third image to obtain contour images corresponding to multiple source characters.
[0161] In some possible implementations, the second acquisition module 702 described above is further configured to:
[0162] The arrangement included in the generated request is set to the preset arrangement; or,
[0163] Based on the type of the target text image to be generated, a preset arrangement method is determined.
[0164] In some possible implementations, the first determining module 703 described above is further configured to:
[0165] The content obtained from the text input box will be determined as the reference text corresponding to the source text;
[0166] Based on a preset extended text template, the reference text is expanded to generate extended text corresponding to the source text.
[0167] In some possible implementations, the first determining module 703 described above is further configured to:
[0168] Using a text generation model, expand the text corresponding to the source text.
[0169] In some possible implementations, the first determining module 703 described above is further configured to:
[0170] Based on the semantic similarity between the source text and each candidate text, multiple candidate texts are generated.
[0171] Display multiple candidate texts;
[0172] The selected candidate text is identified as the extended text corresponding to the source text.
[0173] In some possible implementations, the first determining module 703 described above is further configured to:
[0174] Determine the type of the source text;
[0175] Determine the target text expansion mode based on the type of the source text;
[0176] Based on the target text expansion pattern, the source text is expanded to obtain the corresponding expanded text.
[0177] In some possible implementations, the first generation module 704 described above is further configured to:
[0178] The extended text is encoded using the first encoder to obtain the first feature corresponding to the extended text;
[0179] The contour map is encoded using a second encoder to obtain the second feature corresponding to the contour map.
[0180] The first feature and the second feature are fused to obtain the fused feature;
[0181] The fused features are decoded using a decoder to obtain the text image corresponding to the source text.
[0182] In some possible implementations, the first generation module 704 described above is further configured to:
[0183] Based on preset weight values, the first feature and the second feature are weighted and fused to obtain the fused feature.
[0184] In some possible implementations, the first generation module 704 described above is further configured to:
[0185] Based on the type of the target text image to be generated, a preset weight value is determined; or,
[0186] Determine a preset weight value based on the type of service that triggered the request; or,
[0187] The weight values contained in the generated request are determined to be preset weight values.
[0188] In some possible implementations, the first generation module 704 described above is further configured to:
[0189] Display text and images;
[0190] Upon receiving an editing instruction for a text image, display the weight value adjustment controls;
[0191] Based on the received adjusted weight values, the first feature and the second feature are re-weighted and fused, and a new text image corresponding to the source text is obtained based on the new fused features.
[0192] In some possible implementations, the first generation module 704 described above is further configured to:
[0193] Based on the first training dataset, a first encoder and decoder are trained and obtained, wherein the first training dataset includes text and text-image pairs;
[0194] Based on the second training dataset, the first encoder, and the decoder, a second encoder is trained and obtained. Each second training dataset includes text, text contour maps, and corresponding text images.
[0195] It should be noted that the foregoing explanation of the method for generating text images also applies to the text image generation apparatus of this embodiment, and will not be repeated here.
[0196] In this embodiment, after receiving a text image generation request, the text image generation system first extracts the contours of the source text contained in the request to obtain the contour map corresponding to the source text. Then, it determines the extended text corresponding to the source text. Finally, based on the extended text and the contour map, it generates the text image corresponding to the source text. Thus, by generating text images based on the contour map and extended text corresponding to the source text, the readability of the generated image is ensured, while also improving the richness and creativity of the generated text image content.
[0197] According to embodiments of this disclosure, this disclosure also provides an electronic device, a readable storage medium, and a computer program product.
[0198] Figure 8 A schematic block diagram of an example electronic device 800 that can be used to implement embodiments of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device may also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the present disclosure described and / or claimed herein.
[0199] like Figure 8 As shown, device 800 includes a computing unit 801, which can perform various appropriate actions and processes based on a computer program stored in read-only memory (ROM) 802 or a computer program loaded from storage unit 808 into random access memory (RAM) 803. RAM 803 may also store various programs and data required for the operation of device 800. The computing unit 801, ROM 802, and RAM 803 are interconnected via bus 804. Input / output (I / O) interface 805 is also connected to bus 804.
[0200] Multiple components in device 800 are connected to I / O interface 805, including: input unit 806, such as keyboard, mouse, etc.; output unit 807, such as various types of monitors, speakers, etc.; storage unit 808, such as disk, optical disk, etc.; and communication unit 809, such as network card, modem, wireless transceiver, etc. Communication unit 809 allows device 800 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.
[0201] The computing unit 801 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of the computing unit 801 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. The computing unit 801 performs the various methods and processes described above, such as the method for generating text images. For example, in some embodiments, the method for generating text images can be implemented as a computer software program tangibly contained in a machine-readable medium, such as storage unit 808. In some embodiments, part or all of the computer program can be loaded and / or installed on device 800 via ROM 802 and / or communication unit 809. When the computer program is loaded into RAM 803 and executed by the computing unit 801, one or more steps of the method for generating text images described above can be performed. Alternatively, in other embodiments, the computing unit 801 can be configured to perform the method for generating text images by any other suitable means (e.g., by means of firmware).
[0202] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems-on-a-chip (SoCs), payload-programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.
[0203] The program code used to implement the methods of this disclosure may be written in any combination of one or more programming languages. This program code may be provided to a processor or controller of a general-purpose computer, special-purpose computer, or other programmable data processing apparatus, such that when executed by the processor or controller, the program code causes the functions / operations specified in the flowcharts and / or block diagrams to be implemented. The program code may be executed entirely on a machine, partially on a machine, as a standalone software package partially on a machine and partially on a remote machine, or entirely on a remote machine or server.
[0204] In the context of this disclosure, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0205] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device for displaying information to the user (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor); and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the computer. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).
[0206] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as data servers), or computing systems that include middleware components (e.g., application servers), or computing systems that include frontend components (e.g., user computers with graphical user interfaces or web browsers through which users can interact with implementations of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., communication networks). Examples of communication networks include local area networks (LANs), wide area networks (WANs), the Internet, and blockchain networks.
[0207] Computer systems can include clients and servers. Clients and servers are generally geographically separated and typically interact via communication networks. The client-server relationship is created by computer programs running on the respective computers and having a client-server relationship with each other. A server can be a cloud server, also known as a cloud computing server or cloud host, a hosting product within the cloud computing service ecosystem, addressing the shortcomings of traditional physical hosts and VPS (Virtual Private Server, or simply "VPS") services, such as high management difficulty and weak business scalability. Servers can also be servers for distributed systems or servers incorporating blockchain technology.
[0208] In this embodiment, after receiving a text image generation request, the contours of the source text contained in the request are extracted to obtain the contour map corresponding to the source text. Then, the extended text corresponding to the source text is determined. Finally, based on the extended text and the contour map, the text image corresponding to the source text is generated. Thus, by generating text images based on the contour map and extended text corresponding to the source text, the readability of the generated image is ensured, while the richness and creativity of the generated text image are improved.
[0209] It should be understood that the various forms of processes shown above can be used to rearrange, add, or delete steps. For example, the steps described in this disclosure can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution disclosed in this disclosure can be achieved, and this is not limited herein.
[0210] Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of that feature. In the description of this disclosure, "a plurality of" means at least two, such as two, three, etc., unless otherwise explicitly specified. In the description of this disclosure, the words "if" and "suppose" as used may be interpreted as "when," "in response to a determination," or "in the circumstances."
[0211] The specific embodiments described above do not constitute a limitation on the scope of protection of this disclosure. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this disclosure should be included within the scope of protection of this disclosure.
Claims
1. A method for generating text images, comprising: Obtain a text image generation request; wherein the generation request includes source text; If the generation request does not include the first image containing the source text but includes a font style, then the font outline corresponding to the source text in the font library is rendered based on the font style to generate a second image corresponding to the source text; or if the generation request does not include the first image containing the source text and does not include a font style, then the font outline is rendered based on a preset font style to generate the second image; the outline of the second image is extracted to obtain the outline image corresponding to the source text; wherein, the method of determining the preset font style includes: determining the preset font style based on the type of the target text image to be generated; or determining the preset font style according to the type of the service that triggered the generation request; Based on the semantic similarity between the source text and each candidate text, multiple candidate texts are generated; the multiple candidate texts are displayed; and the selected candidate text is determined as the extended text corresponding to the source text. The extended text is encoded using a first encoder to obtain a first feature corresponding to the extended text; the contour map is encoded using a second encoder to obtain a second feature corresponding to the contour map; the first feature and the second feature are weighted and fused based on a preset weight value to obtain a fused feature; the fused feature is decoded using a decoder to obtain a text image corresponding to the source text; the text image is displayed, and a weight value adjustment control is displayed when an editing instruction for the text image is received; based on the received adjusted weight value, the first feature and the second feature are re-weighted and fused, and a new text image corresponding to the source text is obtained based on the new fused feature; wherein, the first encoder and the decoder are the encoder and decoder in the text-conditional implicit diffusion generation model, and the second encoder is a controllable diffusion generation encoder.
2. The method as described in claim 1, wherein, Obtaining the outline image corresponding to the source text further includes: If the generation request includes a first image containing the source text, the contour of the source text in the first image is extracted to obtain the contour map corresponding to the source text.
3. The method as described in claim 1, wherein, The step of extracting contours from the second image to obtain the contour map corresponding to the source text includes: If the generation request contains multiple source characters, the outlines corresponding to the multiple source characters are rendered to obtain multiple rendered text images. Based on a preset arrangement, the multiple text images are arranged and merged to generate a third image; Contour extraction is performed on the third image to obtain contour images corresponding to the multiple source characters.
4. The method of claim 3, wherein, Before arranging and merging the multiple text images based on a preset arrangement, the method further includes: The arrangement included in the generated request is determined to be the preset arrangement; or, The preset arrangement is determined based on the type of the target text image to be generated.
5. The method of claim 1, wherein, The determination of the extended text corresponding to the source text This includes: The content obtained from the text input box is determined as the reference text corresponding to the source text; Based on a preset extended text template, the reference text is extended to generate the extended text corresponding to the source text.
6. The method of claim 1, wherein, Determine the extended text corresponding to the source text This approach also includes: Using a text generation model, the extended text corresponding to the source text is generated.
7. The method of claim 1, wherein, Determining the extended text corresponding to the source text includes: Determine the type of the source text; Determine the target text expansion mode based on the type of the source text; Based on the target text expansion pattern, the source text is expanded to obtain the expanded text corresponding to the source text.
8. The method of claim 1, wherein, Before the weighted fusion of the first feature and the second feature based on preset weight values to obtain the fused feature, the method further includes: The preset weight value is determined based on the type of the target text image to be generated; or, The preset weight value is determined based on the type of service that triggered the generation request; or, The weight value contained in the generated request is determined as the preset weight value.
9. The method of claim 7, wherein, Before generating the text image corresponding to the source text based on the extended text and the contour map, the method further includes: Based on the first training dataset, the first encoder and the decoder are trained and obtained, wherein the first training dataset includes text and text-image pairs; Based on the second training dataset, the first encoder, and the decoder, the second encoder is trained and obtained, wherein each second training dataset includes text, text contour map, and corresponding text image.
10. A text image generation apparatus, comprising: The first acquisition module is used to acquire a text image generation request, wherein the generation request includes source text; The second acquisition module is configured to: if the generation request does not include the first image containing the source text but the generation request includes a font style, then render the font outline corresponding to the source text in the font library based on the font style to generate a second image corresponding to the source text; or if the generation request does not include the first image containing the source text and the generation request does not include a font style, then render the font outline based on a preset font style to generate the second image; extract the outline of the second image to obtain the outline image corresponding to the source text; wherein, the method of determining the preset font style includes: determining the preset font style based on the type of the target text image to be generated; or determining the preset font style according to the type of the service that triggered the generation request; The first determining module is used to generate multiple candidate texts based on the semantic similarity between the source text and each candidate text; display the multiple candidate texts; and determine the selected candidate text as the extended text corresponding to the source text. The first generation module is configured to: encode the extended text using a first encoder to obtain a first feature corresponding to the extended text; encode the contour map using a second encoder to obtain a second feature corresponding to the contour map; weight and fuse the first feature and the second feature based on a preset weight value to obtain a fused feature; decode the fused feature using a decoder to obtain a text image corresponding to the source text; display the text image, and upon receiving an editing instruction for the text image, display a weight value adjustment control; and re-weight and fuse the first feature and the second feature based on the received adjusted weight value to obtain a new text image corresponding to the source text based on the new fused feature; wherein the first encoder and the decoder are the encoder and decoder in a text-conditional implicit diffusion generation model, and the second encoder is a controllable diffusion generation encoder.
11. The apparatus according to claim 10, wherein, The second acquisition module is also specifically used for: If the generation request includes a first image containing the source text, the contour of the source text in the first image is extracted to obtain the contour map corresponding to the source text.
12. The apparatus according to claim 10, wherein, The second acquisition module is further configured to: If the generation request contains multiple source characters, the outlines corresponding to the multiple source characters are rendered to obtain multiple rendered text images. Based on a preset arrangement, the multiple text images are arranged and merged to generate a third image; Contour extraction is performed on the third image to obtain contour images corresponding to the multiple source characters.
13. The apparatus according to claim 12, wherein, The second acquisition module is further configured to: The arrangement included in the generated request is determined to be the preset arrangement; or, The preset arrangement is determined based on the type of the target text image to be generated.
14. The apparatus according to claim 10, wherein, The first determining module is further configured to: The content obtained from the text input box is determined as the reference text corresponding to the source text; Based on a preset extended text template, the reference text is extended to generate the extended text corresponding to the source text.
15. The apparatus according to claim 10, wherein, The first determining module is further configured to: Using a text generation model, the extended text corresponding to the source text is generated.
16. The apparatus according to claim 10, wherein, The first determining module is further configured to: Determine the type of the source text; Determine the target text expansion mode based on the type of the source text; Based on the target text expansion pattern, the source text is expanded to obtain the expanded text corresponding to the source text.
17. The apparatus according to claim 10, wherein, The first generation module is further configured to: The preset weight value is determined based on the type of the target text image to be generated; or, The preset weight value is determined based on the type of service that triggered the generation request; or, The weight value contained in the generated request is determined as the preset weight value.
18. The apparatus according to claim 10, wherein, The first generation module is further configured to: Based on the first training dataset, the first encoder and the decoder are trained and obtained, wherein the first training dataset includes text and text-image pairs; Based on the second training dataset, the first encoder, and the decoder, the second encoder is trained and obtained, wherein each second training dataset includes text, text contour map, and corresponding text image.
19. An electronic device comprising: 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 at least one processor to enable the at least one processor to perform the method of any one of claims 1-9.
20. A non-transitory computer-readable storage medium storing computer instructions, wherein, The computer instructions are used to cause the computer to perform the method according to any one of claims 1-9.
21. A computer program product comprising a computer program that, when executed by a processor, implements the steps of the method according to any one of claims 1-9.
Citation Information
Patent Citations
Handwritten font generation method and device, electronic equipment and storage medium
CN114283422A
