Sample generation method and device, model training method and device, image generation method and device, equipment and medium
By obtaining the text information of text-type images and performing edge detection, training samples are generated to train the image generation model, which solves the problem of uncontrollable fonts in the diffusion model and achieves the improvement of text generation and intelligent capabilities of multiple fonts.
Patent Information
- Application Number
- CN202410933387.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-12
- Publication Date
- 2024-09-27
AI Technical Summary
The venison diagram method based on the diffusion model cannot control the font of the generated text, especially when generating Chinese text, it cannot generate readable text, and the control of the font by the existing method is limited by the character set.
Generate image text descriptions by obtaining text information of text images, perform edge detection to obtain glyph edge information, and combine this information with image text descriptions and data exchange format information to generate training samples for training image generation models to make the model Ability to learn and generate font-controllable text.
It effectively improves the font controllability of generated text, can generate text in multiple fonts, and is not limited by character sets, enhancing the model's intelligence and generation capabilities.
Smart Images

Figure CN118710756A
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, in particular to the fields of artificial intelligence, deep learning, computer vision, and more specifically to a sample generation, model training, image generation method, device, equipment and medium. Background Art
[0002] The diffusion model has promoted the development of text-generated images with its excellent and high-quality image generation capabilities. The text-generated graph method based on the diffusion model can generate images with diverse styles, but due to the complex and fine-grained structure of visual text, how to generate clear and readable text in the text-generated graph process is still a difficult point.
[0003] In the process of implementing the concept of the present disclosure, the inventors found that there are at least the following problems in the related art: the text graph method based on the diffusion model cannot control the font of the generated text. Summary of the invention
[0004] In view of this, the present disclosure provides a sample generation, model training, image generation method, device, equipment and medium.
[0005] One aspect of the present disclosure provides a method for generating training samples, including: obtaining an image text description generated for text information in a text-type image; performing edge detection on the text-type image to obtain glyph edge information of the text information; and combining the image text description, glyph edge information, the text-type image, and data exchange format information of the text-type image to obtain a training sample determined based on the text-type image.
[0006] One aspect of the present disclosure provides a method for training an image generation model, including: obtaining a target training sample, wherein the target training sample includes a sample text image and a sample image text description of the sample text image, sample glyph edge information and sample data exchange format information, and the target training sample is generated based on the training sample generation method of the present disclosure; inputting a first encoding vector of the sample image text description and a second encoding vector of the sample text image into a first neural network of the image generation model to obtain a first feature vector; inputting the first encoding vector and a third encoding vector of the sample glyph edge information into a second neural network of the image generation model to obtain a second feature vector; inputting the first feature vector and the second feature vector into a third neural network of the image generation model to obtain a third feature vector; decoding the third feature vector to obtain an output text image; and training the second neural network according to the sample data exchange format information, the sample text image and the output text image to obtain a trained image generation model.
[0007] Another aspect of the present disclosure provides an image generation method, including: obtaining glyph edge information of text to be processed; and inputting the glyph edge information and a text description of the image to be processed defined for the text to be processed into an image generation model to obtain an image containing target text, wherein the content of the target text is determined according to the content of the text to be processed, the font of the target text is the same as the font of the text to be processed, and the image generation model is trained based on the training method of the image generation model of the present disclosure.
[0008] One aspect of the present disclosure provides a training sample generating device, including: an image text description acquiring module, used to acquire an image text description generated for text information in a text-type image; an edge detection module, used to perform edge detection on the text-type image to obtain glyph edge information of the text information; and a training sample combining module, used to combine the image text description, glyph edge information, the text-type image and data exchange format information of the text-type image to obtain a training sample determined based on the text-type image.
[0009] One aspect of the present disclosure provides a training device for an image generation model, including: a target training sample acquisition module, used to acquire target training samples, wherein the target training samples include a sample text image and a sample image text description of the sample text image, sample glyph edge information and sample data exchange format information, and the target training samples are generated based on the training sample generation device of the present disclosure; a first neural network module, used to input a first coding vector of the sample image text description and a second coding vector of the sample text image into a first neural network of the image generation model to obtain a first feature vector; a second neural network module, used to input the first coding vector and a third coding vector of the sample glyph edge information into a second neural network of the image generation model to obtain a second feature vector; a third neural network module, used to input the first feature vector and the second feature vector into a third neural network of the image generation model to obtain a third feature vector; a decoding module, used to decode the third feature vector to obtain an output text image; and a training module, used to train the second neural network according to the sample data exchange format information, the sample text image and the output text image to obtain a trained image generation model.
[0010] One aspect of the present disclosure provides an image generation device, including: a glyph edge information acquisition module, used to obtain glyph edge information of a text to be processed; and an image generation module, used to input the glyph edge information and a text description of an image to be processed defined for the text to be processed into an image generation model, to obtain an image containing target text, wherein the content of the target text is determined according to the content of the text to be processed, the font of the target text is the same as the font of the text to be processed, and the image generation model is trained based on a training device for an image generation model of the present disclosure.
[0011] Another aspect of the present disclosure provides an electronic device, comprising: one or more processors; a memory for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement at least one of the training sample generation method, image generation model training method, and image generation method of the present disclosure.
[0012] Another aspect of the present disclosure provides a computer-readable storage medium storing computer-executable instructions, which, when executed, are used to implement at least one of the training sample generation method, image generation model training method, and image generation method of the present disclosure.
[0013] Another aspect of the present disclosure provides a computer program product, which includes computer executable instructions, and the instructions are used to implement at least one of the training sample generation method, image generation model training method, and image generation method of the present disclosure when executed.
[0014] According to the embodiments of the present disclosure, because the technical means of obtaining an image text description generated for text information in a text-type image; performing edge detection on the text-type image to obtain the glyph edge information of the text information; and combining the image text description, glyph edge information, the text-type image, and the data exchange format information of the text-type image to obtain a training sample determined based on the text-type image are adopted, by extracting the glyph edge information as part of the training sample, a mechanism is provided that can better learn the glyph features of the text, so that the model trained based on the sample can effectively learn the glyph features of the input text and enhance the controllability of the font of the generated text. In addition, by combining a combination of multiple information such as the text-type image and its data exchange format information, the image text description, and the glyph edge information, the training sample is constructed and the training model is trained, which can effectively improve the intelligent ability of the trained model and is conducive to generating images with controllable fonts. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] The above and other objects, features and advantages of the present disclosure will become more apparent through the following description of the embodiments of the present disclosure with reference to the accompanying drawings, in which:
[0016] Figure 1 An exemplary system architecture to which at least one of a training sample generation method, an image generation model training method, and an image generation method can be applied according to an embodiment of the present disclosure is schematically shown;
[0017] Figure 2 A flowchart of a method for generating training samples according to an embodiment of the present disclosure is schematically shown;
[0018] Figure 3 A schematic diagram of automatically acquiring text description of an image based on CogVLM according to an embodiment of the present disclosure is schematically shown;
[0019] Figure 4 A schematic diagram schematically shows a method for automatically constructing a training sample set according to an embodiment of the present disclosure;
[0020] Figure 5 A flowchart schematically illustrates a method for training an image generation model according to an embodiment of the present disclosure;
[0021] Figure 6 The schematic diagram shows the structure of ControlNet after the basic diffusion model is introduced according to the embodiment of the present disclosure;
[0022] Figure 7 The flowchart of the image generation method according to the embodiment of the present disclosure is schematically shown;
[0023] Figure 8 A block diagram schematically shows a training sample generating device according to an embodiment of the present disclosure;
[0024] Fig. 9 A block diagram schematically shows a training device for an image generation model according to an embodiment of the present disclosure;
[0025] Fig.10 A block diagram schematically shows an image generating device according to an embodiment of the present disclosure; and
[0026] Fig.11 A block diagram of an electronic device suitable for implementing at least one of the training sample generation method, the image generation model training method, and the image generation method according to an embodiment of the present disclosure is schematically shown. DETAILED DESCRIPTION
[0027] Hereinafter, embodiments of the present disclosure will be described with reference to the accompanying drawings. However, it should be understood that these descriptions are exemplary only and are not intended to limit the scope of the present disclosure. In the following detailed description, for ease of explanation, many specific details are set forth to provide a comprehensive understanding of the embodiments of the present disclosure. However, it is apparent that one or more embodiments may also be implemented without these specific details. In addition, in the following description, descriptions of known structures and technologies are omitted to avoid unnecessary confusion of the concepts of the present disclosure.
[0028] The terms used herein are only for describing specific embodiments and are not intended to limit the present disclosure. The terms "comprise", "include", etc. used herein indicate the existence of the features, steps, operations and / or components, but do not exclude the existence or addition of one or more other features, steps, operations or components.
[0029] All terms (including technical and scientific terms) used herein have the meanings commonly understood by those skilled in the art unless otherwise defined. It should be noted that the terms used herein should be interpreted as having a meaning consistent with the context of this specification and should not be interpreted in an idealized or overly rigid manner.
[0030] When using expressions such as "at least one of A, B, and C, etc.", they should generally be interpreted according to the meaning of the expression commonly understood by those skilled in the art (for example, "a system having at least one of A, B, and C" should include but is not limited to a system having A alone, B alone, C alone, A and B, A and C, B and C, and / or A, B, C, etc.).
[0031] In the embodiments of the present disclosure, the collection, updating, analysis, processing, use, transmission, provision, disclosure, storage, etc. of the data involved (for example, including but not limited to user personal information) are in compliance with the provisions of relevant laws and regulations, are used for legitimate purposes, and do not violate public order and good morals. In particular, necessary measures are taken for user personal information to prevent illegal access to user personal information data and maintain the security of user personal information, network security, and national security.
[0032] In the embodiments of the present disclosure, the user's authorization or consent is obtained before obtaining or collecting the user's personal information.
[0033] The mainstream controllable text-generated graph methods based on diffusion models in related technologies include methods represented by AnyText (a multilingual visual text generation and editing model), TextDiffusers (a text comparison tool) and GlyphByT5 (visual text encoder). These methods can be divided into two categories according to the different technical routes used: AnyText understands the fine-grained information of visual text as glyph images, and guides the diffusion model to generate clear text by controlling the changes of glyph images; TextDiffuser and GlyphByT5 understand the text structure and layout in the image by improving the performance of the text encoder, and then directly conditionally control the generation of clear text.
[0034] In the process of implementing the concept of the present disclosure, the inventors found that AnyText can only control the content of the generated text, but cannot control the font of the generated text. TextDiffuser only encodes and trains English letters and cannot generate readable Chinese text. GlyphByT5 only covers the commonly used Chinese character set when encoding text and cannot generate text that is not in the character set. How to achieve font controllability and not be restricted by the character set during the generation process has become an urgent problem to be solved.
[0035] The embodiments of the present disclosure provide a sample generation, model training, image generation method, device, equipment and medium. The training sample generation method includes: obtaining an image text description generated for text information in a text image; performing edge detection on the text image to obtain the glyph edge information of the text information; and combining the image text description, glyph edge information, text image and data exchange format information of the text image to obtain a training sample determined based on the text image.
[0036] Figure 1 The exemplary system architecture 100 is schematically shown to which at least one of the training sample generation method, the image generation model training method, and the image generation method can be applied according to an embodiment of the present disclosure. It should be noted that: Figure 1 What is shown is merely an example of a system architecture to which the embodiments of the present disclosure can be applied, in order to help those skilled in the art understand the technical content of the present disclosure, but it does not mean that the embodiments of the present disclosure cannot be used in other devices, systems, environments or scenarios.
[0037] like Figure 1 As shown, the system architecture 100 according to this embodiment may include a first terminal device 101, a second terminal device 102, a third terminal device 103, a network 104, and a server 105. The network 104 is used to provide a medium for a communication link between the first terminal device 101, the second terminal device 102, the third terminal device 103, and the server 105. The network 104 may include various connection types, such as wired and / or wireless communication links, etc.
[0038] The user may use the first terminal device 101, the second terminal device 102, and the third terminal device 103 to interact with the server 105 through the network 104 to receive or send messages, etc. Various communication client applications may be installed on the first terminal device 101, the second terminal device 102, and the third terminal device 103, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, and / or social platform software, etc. (only for example).
[0039] The first terminal device 101, the second terminal device 102, and the third terminal device 103 may be various electronic devices having display screens and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, desktop computers, and the like.
[0040] The server 105 may be a server that provides various services, such as a background management server (only as an example) that provides support for websites browsed by users using the first terminal device 101, the second terminal device 102, and the third terminal device 103. The background management server may analyze and process the received data such as user requests, and feed back the processing results (such as web pages, information, or data obtained or generated according to user requests) to the terminal device.
[0041] It should be noted that at least one of the training sample generation method, the image generation model training method, and the image generation method provided in the embodiment of the present disclosure can generally be executed by the server 105. Accordingly, at least one of the training sample generation device, the image generation model training device, and the image generation device provided in the embodiment of the present disclosure can generally be set in the server 105. At least one of the training sample generation method, the image generation model training method, and the image generation method provided in the embodiment of the present disclosure can also be executed by a server or server cluster that is different from the server 105 and can communicate with the first terminal device 101, the second terminal device 102, the third terminal device 103, and / or the server 105. Accordingly, at least one of the training sample generation device, the image generation model training device, and the image generation device provided in the embodiment of the present disclosure can also be set in a server or server cluster that is different from the server 105 and can communicate with the first terminal device 101, the second terminal device 102, the third terminal device 103, and / or the server 105. Alternatively, at least one of the training sample generation method, the image generation model training method, and the image generation method provided in the embodiments of the present disclosure may also be executed by the first terminal device 101, the second terminal device 102, or the third terminal device 103, or may also be executed by other terminal devices different from the first terminal device 101, the second terminal device 102, or the third terminal device 103. Accordingly, at least one of the training sample generation device, the image generation model training device, and the image generation device provided in the embodiments of the present disclosure may also be set in the first terminal device 101, the second terminal device 102, or the third terminal device 103, or may be set in other terminal devices different from the first terminal device 101, the second terminal device 102, or the third terminal device 103.
[0042] For example, the text-type image may be originally stored in any one of the first terminal device 101, the second terminal device 102, or the third terminal device 103 (for example, the first terminal device 101, but not limited thereto), or stored in an external storage device and may be imported into the first terminal device 101. Then, the first terminal device 101 may locally execute the training sample generation method provided by the embodiment of the present disclosure, or send the text-type image to other terminal devices, servers, or server clusters, and the other terminal devices, servers, or server clusters that receive the text-type image may execute the training sample generation method provided by the embodiment of the present disclosure.
[0043] For example, the target training sample may be originally stored in any one of the first terminal device 101, the second terminal device 102 or the third terminal device 103 (for example, the first terminal device 101, but not limited thereto), or stored on an external storage device and may be imported into the first terminal device 101. Then, the first terminal device 101 may locally execute the training method for the image generation model provided in the embodiment of the present disclosure, or send the target training sample to other terminal devices, servers, or server clusters, and the other terminal devices, servers, or server clusters that receive the target training sample may execute the training method for the image generation model provided in the embodiment of the present disclosure.
[0044] For example, the text to be processed may be originally stored in any one of the first terminal device 101, the second terminal device 102 or the third terminal device 103 (for example, the first terminal device 101, but not limited thereto), or stored in an external storage device and may be imported into the first terminal device 101. Then, the first terminal device 101 may locally execute the image generation method provided by the embodiment of the present disclosure, or send the text to be processed to other terminal devices, servers, or server clusters, and the other terminal devices, servers, or server clusters that receive the text to be processed may execute the image generation method provided by the embodiment of the present disclosure.
[0045] It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.
[0046] Figure 2 The flowchart of the training sample generation method according to the embodiment of the present disclosure is schematically shown.
[0047] like Figure 2 As shown, the method includes operations S201 to S203.
[0048] In operation S201, an image text description generated for text information in a text-type image is obtained.
[0049] According to the embodiments of the present disclosure, the text image can represent any image containing text, which is not limited here. The text image can be derived from various open source data sets, or can be generated by user, which is not limited here.
[0050] According to an embodiment of the present disclosure, the image text description may include, for example, the following description form: This image shows a series of Chinese / English / other language characters, and these characters are ABC. The description form of the image text description is not limited to this, as long as it can describe the text information in the text-type image. The image text description can be obtained by an analyst analyzing the text-type image and manually configuring the relevant description sentences, and is not limited to this.
[0051] In operation S202, edge detection is performed on the text image to obtain font edge information of the text information.
[0052] According to an embodiment of the present disclosure, an edge detection algorithm can be used to perform edge detection on a text image to obtain glyph edge information. The edge detection algorithm can use any one of the following: Canny (Canny edge detector, a multi-level edge detection algorithm), Sobel (Sobel edge detection algorithm), Laplace algorithm, etc., and is not limited thereto. Glyph edge information can be used to record the shape of the text, that is, the font.
[0053] According to the embodiments of the present disclosure, the glyph edge information may exist in the form of data information or in the form of an image, which is not limited here. For example, the glyph data information obtained by edge detection may be used as the glyph edge information. For example, the text Canny image obtained by edge detection based on the Canny algorithm may also be used as the glyph edge information.
[0054] In operation S203, the image text description, the glyph edge information, the text type image and the data exchange format information of the text type image are combined to obtain a training sample determined based on the text type image.
[0055] According to an embodiment of the present disclosure, the data exchange format information may represent an information file for recording at least one of the image identification information, image attribute information, text content information, and text location information of a text-type image. For example, the data exchange format information may be JSON (JavaScript Object Notation, JS object notation) information of a text-type image, and may not be limited thereto. As a lightweight data exchange format, JSON is easy to read and write, and is also easy for programs to parse and generate.
[0056] According to an embodiment of the present disclosure, when there is only one text-type image, the text-type image and its image text description, glyph edge information and data exchange format information can be combined as an element to obtain a four-tuple data, and the four-tuple data can be determined as a training sample determined based on the text-type image. When there are multiple text-type images, the above combination operation can be performed for each text-type image to obtain multiple training samples. The text fonts in different text-type images can be different.
[0057] Through the above-mentioned embodiments of the present disclosure, by extracting glyph edge information as part of the training sample, a mechanism is provided that can better learn the glyph features of text, so that the model trained based on the sample can effectively learn the glyph features of the input text, and enhance the controllability of the font of the generated text. In addition, by combining a combination of multiple information such as text-type images and their data exchange format information, image text descriptions, glyph edge information, etc., to construct training samples and train models, the intelligent capabilities of the trained model can be effectively improved, which is conducive to generating images with controllable fonts. For example, after training the text-generated image model using the aforementioned training samples, the controllability of the text font in the generated image can be achieved on the basis of improving the ability to generate images based on text.
[0058] In conjunction with specific embodiments, Figure 2 The method shown is further explained.
[0059] According to an embodiment of the present disclosure, the above operation S201 may include: inputting the text image and a preset description sentence into a multimodal visual language model to obtain a text description of the image, wherein the preset description sentence is a prompt sentence representing the description of the text image.
[0060] According to the embodiments of the present disclosure, text images obtained based on open source datasets may not originally contain image text descriptions, but image text descriptions need to be used to generate text images in the training process. Based on the demand for a large number of image text descriptions, for example, a set of automated processes for obtaining image text descriptions can be designed based on a multimodal visual language model.
[0061] For example, the multimodal visual language model may use a CogVLM model or other multimodal large models, and is not limited thereto. As a multimodal large model based on the fusion understanding between visual and language information, CogVLM can achieve deep fusion of visual and language features. The preset description sentence may be, for example: describe this image.
[0062] Figure 3 The schematic diagram of automatically acquiring text description of an image based on CogVLM according to an embodiment of the present disclosure is schematically shown.
[0063] like Figure 3 As shown, CogVLM 330 can establish a mapping relationship between text and image based on the pre-trained large model 331, based on the image encoder 332 and the text encoder 333, and then complete the task of generating a specific image text description 340 for the text image 310. The preset description sentence 320 and the text image 310 to be described are input into CogVLM 330, and the image text description 340 for the text information in the text image 310 can be obtained.
[0064] It should be noted that the specific statement description of the preset description statement can be changed in response to actual business needs and is not limited to the above description method.
[0065] According to an embodiment of the present disclosure, the text-type image has image identification information. When the image text description is obtained, a mapping relationship between the image text description and the image identification information can be established.
[0066] like Figure 3 As shown, after obtaining the image text description 340, the mapping relationship between the image ID of the text-type image 310 and the image text description 340 can be written into a TXT file 350 to obtain a res.txt file.
[0067] According to an embodiment of the present disclosure, when there are multiple text-type images, the mapping information between the image ID of each text-type image and its corresponding image description information may be recorded in the res.txt file for subsequent reading.
[0068] Through the above-mentioned embodiments of the present disclosure, a set of automatic generation methods for image text descriptions is implemented, which is conducive to reducing manual workload and improving work efficiency.
[0069] According to an embodiment of the present disclosure, the data exchange format information may include position information of the area occupied by the text information. The above operation S202 may include: determining the text area representing the text information in the text image according to the position information. Performing edge detection on the text area to obtain the font edge information of the text information.
[0070] According to an embodiment of the present disclosure, the position information can be represented as the pixel coordinates of the upper left corner of the text area and the width and height information of the text area, or as the information of the corner coordinates of the text area, and is not limited thereto. In the process of edge detection, the text area can be firstly intercepted from the text image according to the position information, and then, for example, the Canny algorithm can be used to perform edge detection on the text area to obtain a Canny image. The Canny image can include glyph edge information that records the characteristics of the text font.
[0071] According to the embodiments of the present disclosure, in some embodiments, when the glyph edge information is obtained, a mapping relationship between the glyph edge information and the image ID of the text-type image may be established for subsequent reading.
[0072] According to an embodiment of the present disclosure, the above operation S203 may include: combining the image text description, the glyph edge information, the text image and the data exchange format information of the text image into a set of image-text data pairs, and determining the image-text data pairs as training samples determined based on the text image.
[0073] According to an embodiment of the present disclosure, the text image and its image text description, glyph edge information and data exchange format information may be combined into a text-image data pair without sequence requirements. Each text-image data pair may constitute a training sample.
[0074] According to the embodiments of the present disclosure, when the image text description, glyph edge information, and training samples corresponding to the text image are available, it is also necessary to establish a paired training sample set according to the sampling format of the diffusion model. To this end, a method for automatically constructing a training sample set can be designed.
[0075] According to an embodiment of the present disclosure, when there are multiple text-type images, the image text description, text-type images, and glyph edge information and data exchange format information of the text-type images with the same image identification information can be combined according to a mapping relationship to obtain a training sample set determined based on multiple text-type images.
[0076] For example, the training sample set may include multiple image-text data pairs.
[0077] Figure 4 The following schematic diagram shows the automatic construction of a training sample set according to an embodiment of the present disclosure.
[0078] like Figure 4 As shown, the open source dataset 400 can provide text images for constructing a training sample set. In the process of automatically constructing a training sample set 450 based on the open source dataset 400, for example, a text image 410 and its image information 420 in JSON format can be first sampled from the open source dataset 410. Then, the position information 421 (the dotted part) representing the position of the text area in the text image 410 can be searched from the image information 420, and the text Canny image 430 can be extracted from the text image 410 based on the position information 421. At the same time, the text image 410 can also be automatically extracted based on the image ID of the text image 410. Figure 3The image text description 440 of the text image 410 is obtained by searching the obtained TXT file 350. Finally, the image information 420 in JSON format, the text Canny image 430, the text image 410 and the image text description 440 after format alignment can be combined into a set of image-text data pairs. After sampling all the text images in the open source data set 400 and performing the above-mentioned processing, the training sample set 450 can be constructed.
[0079] Through the above embodiments of the present disclosure, by establishing a data set for multi-font controllable text generation, a learnable sample for text generation is provided. The training sample set and the training model can effectively improve the intelligent ability of the trained model.
[0080] According to an embodiment of the present disclosure, after the above training samples are obtained, the above training samples can be used to train an image generation model that generates images based on text.
[0081] According to an embodiment of the present disclosure, after generating a training sample set based on the aforementioned training sample generation method, before training the image generation model, the target training sample required for each training round can be first obtained from the training data set. The method may include: obtaining a training sample set, wherein the training set sample includes multiple training samples, and the sample data exchange format information of each training sample includes sample image identification information of a sample text-type image. According to the sample image identification information, the training samples in the training sample set are grouped to obtain a grouping result. According to the grouping result, the training samples belonging to the same group are determined as target training samples.
[0082] According to an embodiment of the present disclosure, the grouping method may include: grouping by individual, grouping by category, etc., and may not be limited thereto. For example, one or more training samples may be grouped into the same group, or Tonglei training samples with similar fonts may be grouped into the same group. The training samples grouped into the same group may be one or more. The target training sample may represent one training sample or multiple training samples in the training sample set, which is not limited here.
[0083] Figure 5 A flowchart of a method for training an image generation model according to an embodiment of the present disclosure is schematically shown.
[0084] like Figure 5 As shown, the method includes operations S501 to S506.
[0085] In operation S501, a target training sample is obtained, wherein the target training sample includes a sample text image and a sample image text description of the sample text image, sample glyph edge information, and sample data exchange format information.
[0086] In operation S502, a first encoding vector of the sample image text description and a second encoding vector of the sample text-type image are input into a first neural network of an image generation model to obtain a first feature vector.
[0087] According to an embodiment of the present disclosure, the sample image text description may be text encoded to obtain a first encoding vector. The sample text image may be image encoded to obtain a second encoding vector. The first neural network may be a feature extraction network, which is used to extract features from the first encoding vector and the second encoding vector to obtain a first feature vector.
[0088] In operation S503, the first encoding vector and the third encoding vector of the sample glyph edge information are input into a second neural network of the image generation model to obtain a second feature vector.
[0089] According to an embodiment of the present disclosure, the sample glyph edge information may be encoded to obtain a third encoding vector. The second neural network may be a feature extraction network, which is used to extract features from the first encoding vector and the third encoding vector to obtain a second feature vector.
[0090] In operation S504, the first eigenvector and the second eigenvector are input into a third neural network of the image generation model to obtain a third eigenvector.
[0091] According to an embodiment of the present disclosure, the third neural network may be a network with a decoding function, which is used to decode the first feature vector and the second feature vector to obtain the second feature vector.
[0092] In operation S505, the third feature vector is decoded to obtain an output text image.
[0093] In operation S506, the second neural network is trained according to the sample data exchange format information, the sample text image and the output text image to obtain a trained image generation model.
[0094] According to an embodiment of the present disclosure, an image generation model can be implemented by introducing a ControlNet bypass to a basic diffusion model. The basic diffusion model can be represented by the first neural network and the third network mentioned above. The ControlNet bypass can be represented by the second neural network mentioned above. The basic diffusion model can be implemented based on VAE and U-Net, but is not limited thereto. VAE, as a variational autoencoder, is a probabilistic generation model. U-Net, as a neural network architecture, is named for its "U"-like model structure and is used for various computer vision tasks. ControlNet, as a neural network that controls a pre-trained diffusion model, can achieve conditional generation by inputting multiple parameters.
[0095] According to an embodiment of the present disclosure, in the process of training the image generation model, a loss value can be calculated based on the sample feature vector of the sample text image and the output feature vector of the output text image, and the loss value can be used to adjust the parameters of the second neural network until the model converges to obtain a trained image generation model.
[0096] Through the above-mentioned embodiments of the present disclosure, by introducing the second neural network to add the glyph features of the text into the image generation model, the controllability of the generated text font can be effectively improved.
[0097] In conjunction with specific embodiments, Figure 5 The method shown is further explained.
[0098] According to an embodiment of the present disclosure, before performing the aforementioned operation S503, the sample glyph edge information may be first downsampled to obtain a third encoding vector, so that the dimension of the third encoding vector is the same as the dimension of the second encoding vector. The aforementioned operation S503 may also be implemented by the following method: first, the second encoding vector and the third encoding vector are fused to obtain a fused encoding vector. Then, the first encoding vector and the fused encoding vector are input into a second neural network to obtain a second feature vector.
[0099] According to an embodiment of the present disclosure, the fused coding vector may be obtained by combining the second coding vector and the third coding vector. The fusion method is not limited thereto.
[0100] It should be noted that when the dimensions of the obtained first coding vector and the second coding vector are different, the first coding vector can also be reduced or increased in dimension by combining a downsampling module or an upsampling module so that the dimensions of the first coding vector and the second coding vector are the same.
[0101] It should be noted that the dimensions of the first encoding vector and the second encoding vector obtained in the embodiment of the present disclosure are the same.
[0102] Figure 6 The schematic diagram shows the structure of ControlNet after the basic diffusion model is introduced according to an embodiment of the present disclosure.
[0103] like Figure 6 As shown, the basic diffusion model 620 may include a text encoder 621, a VAE encoder 622, a U-Net 623, and a VAE decoder 624. Among them, the U-Net 623 may include an encoding module 623_1 and a decoding module 623_2. The ControlNet bypass 630 may include a first downsampling module 631, a second downsampling module 632, and a zero convolution module 633. The basic diffusion model 620 and the ControlNet bypass 630 may constitute the above-mentioned image generation model.
[0104] According to the embodiments of the present disclosure, Figure 3 As shown, the sample image text description 611 in the target training sample 610 can be input into the text encoder 621 for encoding to obtain a first encoding vector. The sample text image 612 in the target training sample 610 can be input into the VAE encoder 622 for encoding to obtain a second encoding vector. The text Canny image 613 in the target training sample 610 can be input into the first downsampling module 631 of the ControlNet bypass 630 to obtain a third encoding vector. The corresponding first encoding vector can be simultaneously input into the ControlNet bypass 630 and the U-Net 623 as a conditional control guide generation, including: inputting the first encoding vector and the second encoding vector into the encoding module 623_1 in the U-Net 623 for encoding to obtain a first feature vector; and the first encoding vector and the third encoding vector, or the first encoding vector and the fused encoding vector obtained by adding the second encoding vector and the third encoding vector, can be input into the second downsampling module 632 of the ControlNet bypass 630 to obtain a second feature vector, and the dimension can be increased through the zero convolution module 633, and added to the result in the corresponding output layer of the U-Net 623 to obtain a third feature vector. The third feature vector output by the U-Net 623 can be decoded by the VAE decoder 624 to obtain an output text image 640.
[0105] According to an embodiment of the present disclosure, during the training of the image generation model, the parameters in U-Net 623 are always kept frozen and are not updated during training. Only the model parameters in ControlNet bypass 630 are updated.
[0106] According to an embodiment of the present disclosure, the sample data exchange format information includes position information representing the area occupied by the text information in the sample text image. The operation S506 may include: based on the position information, intercepting a first text area from the sample text image, and intercepting a second text area from the output text image. Calculating a target loss based on the first text area and the second text area. Training the second neural network based on the target loss.
[0107] According to the embodiments of the present disclosure, Figure 6As shown, the sample text image 612 can be intercepted according to the position information of the text area in the sample text image 612 recorded in the JSON format image information 614 in the target training sample 610 to obtain the above-mentioned first text area, and the output text image 640 can be intercepted to obtain the above-mentioned second text area. Then, the target loss value can be calculated according to the feature vector of the first text area and the feature vector of the second text area, and the model parameters in the ControlNet bypass can be adjusted using the target loss value until the image generation model converges, and the trained image generation model can be obtained.
[0108] Through the above-mentioned embodiments of the present disclosure, by adding a ControlNet bypass to the basic diffusion model, learning high-quality features of glyph edge information based on the ControlNet bypass, and establishing a mapping relationship between edge features and output text content and text fonts, the problem of being unable to control the generated text font can be further alleviated.
[0109] According to an embodiment of the present disclosure, after obtaining a trained image generation model, the image generation model can be used to implement a process of generating an image based on text.
[0110] Figure 7 The flowchart of the image generating method according to the embodiment of the present disclosure is schematically shown.
[0111] like Figure 7 As shown, the method includes operations S701~S702.
[0112] In operation S701, the glyph edge information of the text to be processed is obtained.
[0113] In operation S702, the glyph edge information and the image text description to be processed defined for the text to be processed are input into the image generation model to obtain an image containing the target text, wherein the content of the target text is determined according to the content of the text to be processed, and the font of the target text is the same as the font of the text to be processed.
[0114] According to an embodiment of the present disclosure, the text to be processed may be text written by a user in a preset font. After obtaining the text to be processed, the glyph edge information of the text to be processed may be obtained in combination with an edge detection algorithm. The text description of the image to be processed may be prompt information written by the user based on the text to be processed to represent the image with specific background information that the user wants to generate. The text to be processed and the text description of the image to be processed are input into the image generation model trained based on the aforementioned method, and an image of the text with the font being the corresponding preset font and the content being the corresponding text content may be obtained.
[0115] It should be noted that the same group of text to be processed and text descriptions of images to be processed are input into the image generation model multiple times, and the image content of the obtained images containing the target text can be different, and the color of the text in the image can be different. This information can be randomly generated and will not be elaborated here.
[0116] According to an embodiment of the present disclosure, a large language model may be used to rewrite the style of the image description.
[0117] Through the above-mentioned embodiments of the present disclosure, an effective multi-font controllable text image generation method based on a diffusion model is provided, which can output an image with text written in a specific font.
[0118] Figure 8 The block diagram of a training sample generating device according to an embodiment of the present disclosure is schematically shown.
[0119] like Figure 8 As shown, the training sample generating device 800 includes an image text description acquiring module 810 , an edge detecting module 820 and a training sample combining module 830 .
[0120] The image text description acquisition module 810 is used to acquire the image text description generated for the text information in the text-type image.
[0121] The edge detection module 820 is used to perform edge detection on the text image to obtain the font edge information of the text information.
[0122] The training sample combination module 830 is used to combine the image text description, the glyph edge information, the text type image and the data exchange format information of the text type image to obtain the training sample determined based on the text type image.
[0123] According to an embodiment of the present disclosure, the image text description acquisition module includes a multimodal visual language model processing unit.
[0124] The multimodal visual language model processing unit is used to input a text image and a preset description sentence into the multimodal visual language model to obtain a text description of the image, wherein the preset description sentence is a prompt sentence representing the description of the text image.
[0125] According to an embodiment of the present disclosure, the data exchange format information includes position information of the area occupied by the text information. The edge detection module includes a text area determination unit and an edge detection unit.
[0126] The text area determination unit is used to determine the text area representing text information in the text-type image according to the position information.
[0127] The edge detection unit is used to perform edge detection on the text area to obtain the font edge information of the text information.
[0128] According to an embodiment of the present disclosure, the training sample combination module includes a data pair combination unit and a training sample definition unit.
[0129] The data pair combination unit is used to combine the image text description, the glyph edge information, the text type image and the data exchange format information of the text type image into a set of image-text data pairs.
[0130] The training sample definition unit is used to determine the image-text data pair as a training sample determined based on the text image.
[0131] According to an embodiment of the present disclosure, the text image has image identification information. The training sample generating device further includes a mapping relationship establishing module and a training sample set obtaining module.
[0132] The mapping relationship establishing module is used to establish a mapping relationship between the image text description and the image identification information when the image text description is obtained.
[0133] The training sample set acquisition module is used to combine the image text description, text image, glyph edge information and data exchange format information of the text image with the same image identification information according to the mapping relationship when there are multiple text images, so as to obtain a training sample set determined based on multiple text images.
[0134] Fig. 9 A block diagram of a training device for an image generation model according to an embodiment of the present disclosure is schematically shown.
[0135] like Fig. 9 As shown, the training device 900 of the image generation model includes a target training sample acquisition module 910, a first neural network module 920, a second neural network module 930, a third neural network module 940, a decoding module 950 and a training module 960.
[0136] The target training sample acquisition module 910 is used to acquire target training samples, wherein the target training samples include sample text image samples and sample image text descriptions of text images, sample glyph edge information and sample data exchange format information, and the target training samples are generated based on the training sample method disclosed in the present invention.
[0137] The first neural network module 920 is used to input the first coding vector of the sample image text description and the second coding vector of the sample text type image into the first neural network of the image generation model to obtain a first feature vector.
[0138] The second neural network module 930 is used to input the first encoding vector and the third encoding vector of the sample glyph edge information into the second neural network of the image generation model to obtain a second feature vector.
[0139] The third neural network module 940 is used to input the first eigenvector and the second eigenvector into the third neural network of the image generation model to obtain a third eigenvector.
[0140] The decoding module 950 is used to decode the third feature vector to obtain an output text image.
[0141] The training module 960 is used to train the second neural network according to the sample data exchange format information, the sample text image and the output text image to obtain a trained image generation model.
[0142] According to an embodiment of the present disclosure, the training device of the image generation model also includes a downsampling module.
[0143] The down-sampling module is used to down-sample the sample glyph edge information to obtain a third encoding vector, wherein the dimension of the third encoding vector is the same as the dimension of the second encoding vector.
[0144] According to an embodiment of the present disclosure, the second neural network module includes a fusion unit and a second neural network unit.
[0145] The fusion unit is used to fuse the second coding vector and the third coding vector to obtain a fused coding vector.
[0146] The second neural network unit is used to input the first coding vector and the fused coding vector into the second neural network to obtain a second feature vector.
[0147] According to an embodiment of the present disclosure, the sample data exchange format information includes position information representing the area occupied by the text information in the sample text-type image. The training module includes a capture unit, a loss calculation unit and a training unit.
[0148] The interception unit is used to intercept a first text area from the sample text image and intercept a second text area from the output text image according to the position information.
[0149] The loss calculation unit is used to calculate the target loss according to the first text area and the second text area.
[0150] The training unit is used to train the second neural network according to the target loss.
[0151] According to an embodiment of the present disclosure, the target training sample acquisition module includes a training sample set acquisition unit, a grouping unit and a target training sample definition unit.
[0152] The training sample set acquisition unit is used to acquire a training sample set, wherein the training set sample includes a plurality of training samples, and the sample data exchange format information of each training sample includes sample image identification information of a sample text-type image.
[0153] The grouping unit is used to group the training samples in the training sample set according to the sample image identification information to obtain a grouping result.
[0154] The target training sample definition unit is used to determine the training samples belonging to the same group as target training samples according to the grouping result.
[0155] Fig.10 A block diagram of an image generating device according to an embodiment of the present disclosure is schematically shown.
[0156] like Fig.10 As shown, the image generating device 1000 includes a glyph edge information acquiring module 1010 and an image generating module 1020 .
[0157] The glyph edge information acquisition module 1010 is used to acquire glyph edge information of the text to be processed.
[0158] The image generation module 1020 is used to input the glyph edge information and the image text description to be processed defined for the text to be processed into the image generation model to obtain an image containing the target text, wherein the content of the target text is determined according to the content of the text to be processed, and the font of the target text is the same as the font of the text to be processed, and the image generation model is trained based on the method of any one of claims 6-9.
[0159] According to the embodiments of the present invention, any multiple of the modules and units, or at least part of the functions of any multiple of them, can be implemented in one module. According to the embodiments of the present invention, any one or more of the modules and units can be split into multiple modules for implementation. According to the embodiments of the present invention, any one or more of the modules and units can be at least partially implemented as a hardware circuit, such as a field programmable gate array (FPGA), a programmable logic array (PLA), a system on a chip, a system on a substrate, a system on a package, an application-specific integrated circuit (ASIC), or can be implemented by hardware or firmware in any other reasonable way of integrating or packaging the circuit, or in any one of the three implementation methods of software, hardware and firmware, or in any appropriate combination of any of them. Alternatively, according to the embodiments of the present invention, one or more of the modules and units can be at least partially implemented as a computer program module, and when the computer program module is run, the corresponding function can be executed.
[0160] For example, any of the image text description acquisition module 810, the edge detection module 820 and the training sample combination module 830, or the target training sample acquisition module 910, the first neural network module 920, the second neural network module 930, the third neural network module 940, the decoding module 950 and the training module 960, or the glyph edge information acquisition module 1010 and the image generation module 1020 can be combined into one module / unit for implementation, or any of the modules / units can be split into multiple modules / units. Alternatively, at least part of the functions of one or more of these modules / units can be combined with at least part of the functions of other modules / units and implemented in one module / unit. According to an embodiment of the present disclosure, at least one of the image text description acquisition module 810, the edge detection module 820 and the training sample combination module 830, or the target training sample acquisition module 910, the first neural network module 920, the second neural network module 930, the third neural network module 940, the decoding module 950 and the training module 960, or the glyph edge information acquisition module 1010 and the image generation module 1020 can be at least partially implemented as a hardware circuit, such as a field programmable gate array (FPGA), a programmable logic array (PLA), a system on a chip, a system on a substrate, a system on a package, an application specific integrated circuit (ASIC), or can be implemented by hardware or firmware such as any other reasonable way of integrating or packaging the circuit, or can be implemented in any one of the three implementation methods of software, hardware and firmware or in a suitable combination of any of them. Alternatively, the image text description acquisition module 810, the edge detection module 820 and the training sample combination module 830, or the target training sample acquisition module 910, the first neural network module 920, the second neural network module 930, the third neural network module 940, the decoding module 950 and the training module 960, or at least one of the glyph edge information acquisition module 1010 and the image generation module 1020 can be at least partially implemented as a computer program module, which can perform corresponding functions when the computer program module is executed.
[0161] It should be noted that the training sample generating device, the training device of the image generation model, and the image generating device part in the embodiments of the present disclosure respectively correspond to the training sample generating method, the training method of the image generation model, and the image generating method part in the embodiments of the present disclosure. The descriptions of the training sample generating device, the training device of the image generation model, and the image generating device part specifically refer to the training sample generating method, the training method of the image generation model, and the image generating method part, and will not be repeated here.
[0162] Fig.11A block diagram of an electronic device suitable for implementing at least one of the training sample generation method, the image generation model training method, and the image generation method according to an embodiment of the present disclosure is schematically shown. Fig.11 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
[0163] like Fig.11 As shown, the electronic device 1100 according to an embodiment of the present disclosure includes a processor 1101, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 1102 or a program loaded from a storage part 1108 to a random access memory (RAM) 1103. The processor 1101 may include, for example, a general-purpose microprocessor (e.g., a CPU), an instruction set processor and / or a related chipset and / or a dedicated microprocessor (e.g., an application-specific integrated circuit (ASIC)), etc. The processor 1101 may also include an onboard memory for caching purposes. The processor 1101 may include a single processing unit or multiple processing units for performing different actions of the method flow according to an embodiment of the present disclosure.
[0164] In RAM 1103, various programs and data required for the operation of electronic device 1100 are stored. Processor 1101, ROM 1102 and RAM 1103 are connected to each other through bus 1104. Processor 1101 performs various operations of the method flow according to the embodiment of the present disclosure by executing the program in ROM 1102 and / or RAM 1103. It should be noted that the program can also be stored in one or more memories other than ROM 1102 and RAM 1103. Processor 1101 can also perform various operations of the method flow according to the embodiment of the present disclosure by executing the program stored in the one or more memories.
[0165] According to an embodiment of the present disclosure, the electronic device 1100 may further include an input / output (I / O) interface 1105, which is also connected to the bus 1104. The electronic device 1100 may further include one or more of the following components connected to the input / output (I / O) interface 1105: an input portion 1106 including a keyboard, a mouse, etc.; an output portion 1107 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage portion 1108 including a hard disk, etc.; and a communication portion 1109 including a network interface card such as a LAN card, a modem, etc. The communication portion 1109 performs communication processing via a network such as the Internet. A drive 1110 is also connected to the input / output (I / O) interface 1105 as needed. A removable medium 1111, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 1110 as needed, so that a computer program read therefrom is installed into the storage portion 1108 as needed.
[0166] According to an embodiment of the present disclosure, the method flow according to an embodiment of the present disclosure can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a computer-readable storage medium, and the computer program contains a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 1109, and / or installed from the removable medium 1111. When the computer program is executed by the processor 1101, the above-mentioned functions defined in the system of the embodiment of the present disclosure are executed. According to an embodiment of the present disclosure, the system, equipment, device, module, unit, etc. described above can be implemented by a computer program module.
[0167] The present disclosure also provides a computer-readable storage medium, which may be included in the device / apparatus / system described in the above embodiments; or may exist independently without being assembled into the device / apparatus / system. The above computer-readable storage medium carries one or more programs, and when the above one or more programs are executed, the method according to the embodiment of the present disclosure is implemented.
[0168] According to an embodiment of the present disclosure, the computer-readable storage medium may be a non-volatile computer-readable storage medium. For example, it may include but is not limited to: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that may be used by or in combination with an instruction execution system, apparatus, or device.
[0169] For example, according to an embodiment of the present disclosure, the computer-readable storage medium may include the ROM 1102 and / or the RAM 1103 described above and / or one or more memories other than the ROM 1102 and the RAM 1103 .
[0170] An embodiment of the present disclosure also includes a computer program product, which includes a computer program, which contains program code for executing the method provided by the embodiment of the present disclosure. When the computer program product runs on an electronic device, the program code is used to enable the electronic device to implement at least one of the training sample generation method, image generation model training method, and image generation method provided by the embodiment of the present disclosure.
[0171] When the computer program is executed by the processor 1101, the above functions defined in the system / device of the embodiment of the present disclosure are executed. According to the embodiment of the present disclosure, the system, device, module, unit, etc. described above can be implemented by a computer program module.
[0172] In one embodiment, the computer program may rely on tangible storage media such as optical storage devices, magnetic storage devices, etc. In another embodiment, the computer program may also be transmitted and distributed in the form of signals on a network medium, and downloaded and installed through the communication part 1109, and / or installed from a removable medium 1111. The program code contained in the computer program may be transmitted using any appropriate network medium, including but not limited to: wireless, wired, etc., or any suitable combination of the above.
[0173] According to an embodiment of the present disclosure, the program code for executing the computer program provided by the embodiment of the present disclosure can be written in any combination of one or more programming languages. Specifically, these computing programs can be implemented using high-level process and / or object-oriented programming languages, and / or assembly / machine languages. Programming languages include, but are not limited to, Java, C++, python, "C" language or similar programming languages. The program code can be executed entirely on the user computing device, partially on the user device, partially on the remote computing device, or entirely on the remote computing device or server. In the case of a remote computing device, the remote computing device can be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computing device (for example, using an Internet service provider to connect through the Internet).
[0174] The flowcharts and block diagrams in the accompanying drawings illustrate the possible implementation architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each box in the flowchart or block diagram may represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of the code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box may also occur in an order different from that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flowchart, and the combination of boxes in the block diagram or flowchart, can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions. It can be understood by those skilled in the art that the features recorded in the various embodiments of the present disclosure can be combined and / or combined in a variety of ways, even if such a combination or combination is not explicitly recorded in the present disclosure. In particular, without departing from the spirit and teaching of the present disclosure, the features described in the various embodiments of the present disclosure may be combined and / or combined in a variety of ways. All of these combinations and / or combinations fall within the scope of the present disclosure.
[0175] The embodiments of the present disclosure are described above. However, these embodiments are only for illustrative purposes and are not intended to limit the scope of the present disclosure. Although the embodiments are described above, this does not mean that the measures in the various embodiments cannot be used in combination to advantage. Without departing from the scope of the present disclosure, those skilled in the art may make a variety of substitutions and modifications, which should all fall within the scope of the present disclosure.
Claims
1. A training sample generation method, comprising: Obtaining an image text description generated for text information in a text-type image; Performing edge detection on the text image to obtain the font edge information of the text information; as well as The image text description, the glyph edge information, the text-type image and the data exchange format information of the text-type image are combined to obtain a training sample determined based on the text-type image.
2. The method according to claim 1, wherein: The step of obtaining the image text description generated based on the text information in the text-type image includes: The text-type image and a preset description sentence are input into a multimodal visual language model to obtain the text description of the image, wherein the preset description sentence is a prompt sentence representing the description of the text-type image.
3. The method according to claim 1, wherein: The data exchange format information includes the position information of the area occupied by the text information; the edge detection of the text image to obtain the font edge information of the text information includes: Determining, based on the position information, a text area in the text image representing the text information; and Perform edge detection on the text area to obtain font edge information of the text information.
4. The method according to claim 1, wherein: The step of combining the image text description, the glyph edge information, the text image and the data exchange format information of the text image to obtain a training sample determined based on the text image includes: Combining the image text description, the glyph edge information, the text type image and the data exchange format information of the text type image into a set of image-text data pairs; and The image-text data pair is determined as the training sample determined based on the text-type image.
5. The method according to any one of claims 1 to 4, wherein: The text image has image identification information; the method further includes: When the image text description is obtained, a mapping relationship between the image text description and the image identification information is established; and In the case where there are multiple text-type images, the image text description, text-type images, and glyph edge information and data exchange format information of the text-type images with the same image identification information are combined according to the mapping relationship to obtain a training sample set determined based on the multiple text-type images.
6. A training method for an image generation model, comprising: Acquire a target training sample, wherein the target training sample includes a sample text image and a sample image text description of the sample text image, sample glyph edge information, and sample data exchange format information, and the target training sample is generated based on the method according to any one of claims 1 to 5; Inputting the first encoding vector of the sample image text description and the second encoding vector of the sample text-type image into the first neural network of the image generation model to obtain a first feature vector; Inputting the first encoding vector and the third encoding vector of the sample glyph edge information into a second neural network of the image generation model to obtain a second feature vector; Inputting the first eigenvector and the second eigenvector into a third neural network of the image generation model to obtain a third eigenvector; Decoding the third feature vector to obtain an output text-type image; and The second neural network is trained according to the sample data exchange format information, the sample text image and the output text image to obtain a trained image generation model.
7. The method according to claim 6, further comprising: Before inputting the first coding vector and the third coding vector of the sample glyph edge information into the second neural network of the image generation model to obtain the second feature vector, Downsampling the sample glyph edge information to obtain the third encoding vector, wherein the dimension of the third encoding vector is the same as the dimension of the second encoding vector; Inputting the first encoding vector and the third encoding vector of the sample glyph edge information into the second neural network of the image generation model to obtain the second feature vector comprises: fusing the second coding vector and the third coding vector to obtain a fused coding vector; and The first encoding vector and the fused encoding vector are input into the second neural network to obtain the second feature vector.
8. The method according to claim 6, wherein: The sample data exchange format information includes position information representing the area occupied by the text information in the sample text-type image; The training of the second neural network according to the sample data exchange format information, the sample text image and the output text image comprises: According to the position information, a first text area is intercepted from the sample text image, and a second text area is intercepted from the output text image; Calculating a target loss based on the first text area and the second text area; and The second neural network is trained according to the target loss.
9. The method according to any one of claims 6 to 8, wherein: The obtaining of target training samples comprises: Acquire a training sample set, wherein the training set sample includes a plurality of training samples, and the sample data exchange format information of each training sample includes the sample image identification information of the sample text-type image; According to the sample image identification information, the training samples in the training sample set are grouped to obtain a grouping result; and According to the grouping result, the training samples belonging to the same group are determined as the target training samples.
10. A method for generating an image, comprising: Get the glyph edge information of the text to be processed; as well as The glyph edge information and the image text description to be processed defined for the text to be processed are input into an image generation model to obtain an image containing the target text, wherein the content of the target text is determined according to the content of the text to be processed, the font of the target text is the same as the font of the text to be processed, and the image generation model is trained based on the method described in any one of claims 6-9.
11. A training sample generating device, comprising: An image text description acquisition module is used to acquire an image text description generated based on text information in a text-type image; An edge detection module is used to perform edge detection on the text image to obtain the font edge information of the text information; as well as The training sample combination module is used to combine the image text description, the glyph edge information, the text type image and the data exchange format information of the text type image to obtain a training sample determined based on the text type image.
12. A training device for an image generation model, comprising: a target training sample acquisition module, used to acquire a target training sample, wherein the target training sample includes a sample text-type image and a sample image text description of the sample text-type image, sample glyph edge information and sample data exchange format information, and the target training sample is generated based on the apparatus according to claim 11; A first neural network module, used for inputting a first coding vector of the sample image text description and a second coding vector of the sample text-type image into a first neural network of an image generation model to obtain a first feature vector; A second neural network module, used for inputting the first encoding vector and the third encoding vector of the sample glyph edge information into a second neural network of the image generation model to obtain a second feature vector; A third neural network module, used for inputting the first feature vector and the second feature vector into a third neural network of the image generation model to obtain a third feature vector; A decoding module, used for decoding the third feature vector to obtain an output text-type image; and A training module is used to train the second neural network according to the sample data exchange format information, the sample text image and the output text image to obtain a trained image generation model.
13. An image generating device, comprising: A glyph edge information acquisition module, used to acquire glyph edge information of the text to be processed; as well as An image generation module is used to input the glyph edge information and the image text description to be processed defined for the text to be processed into an image generation model to obtain an image containing target text, wherein the content of the target text is determined according to the content of the text to be processed, the font of the target text is the same as the font of the text to be processed, and the image generation model is trained based on the device described in claim 12.
14. An electronic device comprising: one or more processors; a memory for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 10.
15. A computer-readable storage medium having executable instructions stored thereon, which, when executed by a processor, enables the processor to implement the method according to any one of claims 1 to 10.
16. A computer program product comprising a computer program, which, when executed by a processor, implements the method according to any one of claims 1 to 10.
