Text-based picture generation method and apparatus, model training method and apparatus, device, and storage medium
Through the image description text expansion model, simple descriptions are expanded into standardized descriptions, which solves the problem of low image quality caused by users' difficulty in providing high-quality descriptions, and achieves high-quality image generation.
Patent Information
- Application Number
- PCT/CN2024/070118
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-03-03
- Filing Date
- 2024-01-02
- Publication Date
- 2024-09-12
AI Technical Summary
When users generate pictures, they need to enter professional and complex picture description text to obtain high-quality pictures. However, it is difficult for non-professional users to provide such descriptions, resulting in low-quality generated pictures.
Through the picture description text expansion model, the simple picture description text is expanded into a standardized picture description text, including words for primary and secondary description objects, thereby generating richer picture description text and improving picture quality.
Users only need to enter simple image description text to generate high-quality images, which improves the richness and beauty of image generation and reduces the difficulty for users to enter complex descriptions.
Smart Images

Figure CN2024070118_12092024_PF_FP_ABST
Abstract
Description
Method for generating images based on text, model training method, device, equipment and storage medium
[0001] Related applications
[0002] This application claims priority to Chinese patent application number 2023102405459, filed on March 3, 2023, entitled “Method, device, apparatus and storage medium for generating images based on text,” the entire text of which is hereby incorporated by reference. Technical Field
[0003] The embodiments of the present application relate to the field of computer technology, and in particular to a method, apparatus, device, and storage medium for generating an image based on text. Background Art
[0004] When users post comments or community posts, they often need to create images that suit their personalized needs. With the continuous development of computer technology, text-based image generation technologies have gradually emerged. Users only need to enter text describing the image to instruct the device to generate the corresponding image.
[0005] Generating high-quality images based on image descriptions requires specialized and complex descriptions. For example, to generate a high-quality image of a mountain, you might need to input descriptions in the following format: mountain, majestic, awe-inspiring, snow-capped, tranquil, vast, peak, misty, rolling, hilly, lush, valley, breathtaking, horizon, and scenic.
[0006] For non-professional users, entering such professional and complex image descriptions is very difficult. Usually, users can only enter a basic concept, such as "mountain" or "sea". Because the image description text entered by users is too simple, the quality of the generated image is low.
[0007] Summary of the Invention
[0008] Embodiments of the present application provide a method, apparatus, device, and storage medium for generating images based on text, as well as a method, apparatus, device, and storage medium for training an image description text expansion model.
[0009] In one aspect, a method for generating an image based on text is provided, the method comprising:
[0010] Obtaining a first picture description text, where the first picture description text is used to describe the picture content of the picture to be generated;
[0011] Performing text expansion on the first picture description text to obtain a second picture description text using a picture description text expansion model, wherein the picture description text expansion model is trained based on respective standard picture description texts and simplified picture description texts of a plurality of reference pictures, and is used to expand the simplified picture description texts into corresponding standard picture description texts, wherein the standard picture description texts include a plurality of words for describing a primary description object of the reference picture and at least one word for describing a secondary description object of the reference picture, and the simplified picture description texts are keywords in the standard picture description texts for describing the primary description object; and
[0012] Generate a picture based on the second picture description text.
[0013] In another aspect, a method for training a picture description text expansion model for picture generation is provided, the method comprising:
[0014] Obtain the description of the picture on the Internet as standard picture description text;
[0015] Extracting keywords from the standard image description text, and using the extracted keywords as a concise image description text; and
[0016] Based on the standard picture description text and the simplified picture description text, a picture description text expansion model is trained. The picture description text expansion model is a model for expanding the picture description text used to generate pictures.
[0017] In another aspect, a device for generating an image based on text is provided, the device comprising:
[0018] An acquisition module, configured to acquire a first picture description text, where the first picture description text is used to describe the picture content of the picture to be generated;
[0019] an expansion module, configured to perform text expansion on the first picture description text using a picture description text expansion model to obtain a second picture description text, wherein the picture description text expansion model is trained based on the respective standard picture description texts and simplified picture description texts of a plurality of reference pictures, and is configured to expand the simplified picture description texts into the corresponding standard picture description texts, wherein the standard picture description texts include a plurality of words for describing a primary description object of the reference picture and at least one word for describing a secondary description object of the reference picture, and the simplified picture description texts are keywords in the standard picture description texts for describing the primary description objects; and
[0020] A generation module is used to generate a picture based on the second picture description text.
[0021] In another aspect, a device for training a picture description text expansion model for picture generation is provided, the device comprising:
[0022] The acquisition module is used to obtain the description of the picture on the Internet as a standard picture description text;
[0023] An extraction module, configured to extract keywords from the standard image description text and use the extracted keywords as a simplified image description text; and
[0024] A training module is used to train a picture description text expansion model based on the standard picture description text and the simplified picture description text. The picture description text expansion model is a model for expanding the picture description text used to generate pictures.
[0025] On the other hand, a computer device is provided, comprising a processor and a memory, wherein the memory stores at least one computer-readable instruction, and the at least one computer-readable instruction is loaded and executed by the processor to implement the method described in the above aspect.
[0026] On the other hand, a computer-readable storage medium is provided, wherein at least one computer-readable instruction is stored in the computer-readable storage medium, and the at least one computer-readable instruction is loaded and executed by a processor to implement the method described in the above aspect.
[0027] On the other hand, a computer program product is provided, comprising computer-readable instructions, wherein the computer-readable instructions are loaded and executed by a processor to implement the method according to the above aspect.
[0028] The details of one or more embodiments of the present application are set forth in the accompanying drawings and the description below. Other features and advantages of the present application will become apparent from the description, drawings, and claims. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the conventional technology, the following briefly introduces the drawings required for use in the embodiments or the conventional technology descriptions. Obviously, the drawings described below are merely embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on the disclosed drawings without any creative work.
[0030] FIG1 is a schematic diagram of an implementation environment provided by an embodiment of the present application;
[0031] FIG2 is a flow chart of a method for generating an image based on text provided in an embodiment of the present application;
[0032] FIG3 is a flow chart of a method for generating an image based on text provided in an embodiment of the present application;
[0033] FIG4 is a schematic diagram of a picture description text expansion model provided in an embodiment of the present application;
[0034] FIG5 is a schematic diagram of an image generation model provided in an embodiment of the present application;
[0035] FIG6 is a schematic diagram of a correlation model provided in an embodiment of the present application;
[0036] FIG7 is a schematic diagram of a quality assessment model provided in an embodiment of the present application;
[0037] FIG8 is a flow chart of a method for generating an image based on text provided in an embodiment of the present application;
[0038] FIG9 is a flowchart of a method for training a picture description text expansion model for picture generation provided in an embodiment of the present application;
[0039] FIG10 is a schematic structural diagram of a device for generating an image based on text provided in an embodiment of the present application;
[0040] FIG11 is a schematic structural diagram of another apparatus for generating an image based on text provided in an embodiment of the present application;
[0041] FIG12 is a structural diagram of a device for training a picture description text expansion model for picture generation provided in an embodiment of the present application;
[0042] FIG13 is a schematic structural diagram of a terminal provided in an embodiment of the present application;
[0043] FIG14 is a schematic diagram of the structure of a server provided in an embodiment of the present application. DETAILED DESCRIPTION
[0044] The following will be combined with the accompanying drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of the embodiments. Based on the embodiments of this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.
[0045] It is understood that the terms "first," "second," and so forth, used herein may be used to describe various concepts, but unless otherwise specified, these concepts are not limited by these terms. These terms are used solely to distinguish one concept from another. For example, a first image may be referred to as a second image, and similarly, a second image may be referred to as a first image, without departing from the scope of this application.
[0046] Here, "at least one" refers to one or more than one. For example, at least one picture can be one picture, two pictures, three pictures, or any other integer greater than or equal to one. "Multiple" refers to two or more than two. For example, "multiple pictures" can be two pictures, three pictures, or any other integer greater than or equal to two. "Each" refers to each of at least one. For example, "each picture" refers to each picture in the multiple pictures. If the multiple pictures are three pictures, "each picture" refers to each of the three pictures.
[0047] It is understandable that in the implementation of this application, related data such as user information is involved. When the above embodiments of this application are applied to specific products or technologies, user permission or consent is required, and the collection, use and processing of relevant data must comply with relevant laws, regulations and standards of relevant countries and regions.
[0048] The method for generating images based on text provided in the embodiments of the present application can be applied to any scenario where images need to be generated.
[0049] For example, in the scenario of information publishing: when users post comments or community posts, they often need to create pictures that meet their personalized expression needs. If the text-based picture generation method provided in the embodiment of the present application is adopted, the user only needs to enter a simple picture description text, or even just enter a word, to generate a content-rich picture, thereby improving the quality of the generated picture.
[0050] For example, it is applied to painting creation scenarios: since text-based image generation is random and diverse, if the method of text-based image generation provided in the embodiment of the present application is adopted, the user only needs to enter a simple image description text, or even just enter a word, to randomly generate images of corresponding content. The user can find creative inspiration from the randomly generated images for creation.
[0051] It should be noted that the embodiments of this application only use information publishing scenarios and painting creation scenarios as examples to illustrate scenarios where images need to be generated, and do not limit the scenarios where images need to be generated. In other embodiments, the scenarios where images need to be generated can also be work-assisted scenarios, etc. Work-assisted scenarios refer to scenarios where text is input through an interactive interface implemented by a computer program when performing work that requires image generation, and images generated based on the text are output.
[0052] The method for generating an image based on text provided in the embodiment of the present application is executed by a terminal. Optionally, the terminal is a smart phone, tablet computer, laptop computer, desktop computer, smart speaker, smart TV, smart watch, or handheld portable gaming device, etc., but is not limited thereto.
[0053] The picture description text expansion model training method for picture generation provided in an embodiment of the present application is executed by a computer device. Optionally, the computer device is a terminal. The terminal can be a smart phone, a tablet computer, a laptop computer, a desktop computer, a smart speaker, a smart TV, a smart watch or a handheld portable gaming device, etc., but is not limited to this. Optionally, the computer device is a server. The server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms.
[0054] FIG1 is a schematic diagram of an implementation environment provided by an embodiment of the present application. As shown in FIG1 , the implementation environment includes a terminal 101 and a server 102. Terminal 101 and server 102 are directly or indirectly connected via wired or wireless communication. FIG1 only uses the connection between server 102 and terminal 101 as an example. In addition, server 102 can be connected to other terminals.
[0055] In some embodiments, a target application provided by server 102 is installed on terminal 101. Terminal 101 can use this target application to implement functions such as data transmission and message exchange. Optionally, the target application is a target application in the operating system of terminal 101, or a target application provided by a third party. For example, the target application is an image generation application that has the function of generating images. Of course, the image generation application can also have other functions, such as sharing functions and commenting functions.
[0056] In some embodiments, terminal 101 obtains a user-entered image description and sends it to server 102. Server 102 generates an image based on the image description and sends it to terminal 101. Terminal 101 receives and displays the image. In other embodiments, terminal 101 obtains a user-entered image description and generates an image based on it. Server 102 is configured to update the process by which terminal 101 generates an image based on the image description.
[0057] FIG2 is a flow chart of a method for generating an image based on text provided in an embodiment of the present application. The embodiment of the present application is exemplified by taking a terminal as an execution subject. Referring to FIG2 , the method includes:
[0058] 201. The terminal obtains a first picture description text, where the first picture description text is used to describe the picture content of the picture to be generated.
[0059] The picture description text describes the picture content in text form. The picture description text can contain characters in any language and can also contain punctuation marks. For example, the picture description text contains Chinese words such as "mountain", "river", "sea", etc. Also, for example, the picture description text can contain English words such as "mountain (mountain)", "girl (little girl)", etc. In the embodiments of the present application, the terminal can generate a picture based on the picture description text, and the first picture description text is the picture description text used to generate the picture.
[0060] In some embodiments, the first picture description text is input by the user. Optionally, the terminal displays a picture generation interface, which is an interface for generating pictures based on text. The picture generation interface displays a picture description text input box, and the picture description text input in the picture description text input box is obtained to get the first picture description text. In other embodiments, the first picture description text is sent to the terminal by other devices, or the first picture description text is found by the terminal from the network. The embodiments of the present application do not limit the acquisition method of the first picture description text.
[0061] 202. The terminal expands the first picture description text through a picture description text expansion model to obtain a second picture description text. The picture description text expansion model is trained based on the respective standard picture description texts and concise picture description texts of multiple reference pictures, and is used to expand the concise picture description text into the corresponding standard picture description text. The standard picture description text includes multiple words for describing the main description objects of the reference picture and at least one word for describing the secondary description objects of the reference picture. The concise picture description text is the keyword for describing the main description object in the standard picture description text.
[0062] Since the first picture description text is used to describe the picture content of the picture to be generated, therefore, the simpler the first picture description text is, the less rich the picture content generated based on the first picture description text is, the less beautiful the background is, and the lower the picture quality is; on the contrary, the richer the first picture description text is, the richer the picture content generated based on the first picture description text is, the more beautiful the background is, and the higher the picture quality is. In order to generate a picture with a relatively high quality based on the picture description text, in the embodiments of the present application, after obtaining the first picture description text, the first picture description text will be expanded through the picture description text expansion model to obtain a second picture description text with rich content, and a picture will be generated based on the second picture description text. Among them, the picture description text expansion model can be any natural language generation model, and the embodiments of the present application do not limit the picture description text expansion model.
[0063] Since the image description text expansion model is trained based on the canonical image description text and simplified image description text of multiple reference images, and the canonical image description text includes multiple words describing the primary descriptive object of the reference image and at least one word used to describe the secondary descriptive object of the reference image, and the simplified image description text is the keyword used to describe the primary descriptive object in the canonical image description text, the image description text expansion model can expand other words describing the primary descriptive object based on the keyword describing the primary descriptive object, and can also expand words describing the secondary descriptive objects, making the expanded image description text rich in content. In other words, the user only needs to enter a word, and the image description text expansion model can expand the content-rich image description text.
[0064] For example, the first picture description text input by the user is "mountain". The picture description text expansion model can not only expand other words to describe the mountain, such as "valley", "mountain range", "canyon", "dangerous peak", "hills" and other words, but also because snow and mountains, clouds and fog and mountains often appear in the same picture, the picture description text expansion model can also expand words such as "snow-capped" and "clouds" to describe other secondary description objects.
[0065] 203. The terminal generates a picture based on the second picture description text.
[0066] For example, if the first picture description text entered by the user is "little girl", the terminal can generate a picture of the little girl based on the first picture description text. However, since the first picture description text only includes "little girl" and does not indicate the background, the background of the little girl in the picture is blurred, and the quality of the generated picture is poor. However, by performing text expansion on the first picture description text in step 202, a second picture description text can be obtained, such as "little girl, cute, long hair, round face, flowers, running". Based on the second picture description text, a picture of a little girl running in a garden can be generated. This picture supplements the background information, is rich in content, and has a high quality of image generation.
[0067] The embodiment of the present application provides a solution for generating pictures based on text, which first uses a picture description text expansion model to perform text expansion on a first picture description text to obtain a second picture description text, and then generates a picture through the second picture description text. Since the picture description text expansion model is trained based on the standard picture description text and simplified picture description text of multiple reference pictures, and the standard picture description text includes multiple words describing the main description object of the reference picture and at least one word used to describe the secondary description object of the reference picture, and the simplified picture description text is a keyword used to describe the main description object in the standard picture description text, the picture description text expansion model can expand other words describing the main description object based on the keyword describing the main description object, and can also expand words describing the secondary description object, so that the expanded picture description text is rich in content, and the picture generated based on the expanded picture description text is rich in content, thereby improving the quality of picture generation.
[0068] FIG3 is a flow chart of a method for generating an image based on text provided in an embodiment of the present application. The embodiment of the present application is exemplified by taking a terminal as an execution subject. Referring to FIG3 , the method includes:
[0069] 301. The terminal obtains a first picture description text, where the first picture description text is used to describe the picture content of the picture to be generated.
[0070] The step 301 is similar to the above step 201 and will not be described in detail here.
[0071] 302. The terminal determines, through the picture description text expansion model and based on the first picture description text, a sampling parameter of a word in the vocabulary, where the sampling parameter is used to represent a probability of the word being sampled as a word in the second picture description text.
[0072] The vocabulary includes multiple words, and the multiple words in the vocabulary can be determined based on experience or implementation scenarios. The embodiments of the present application do not limit the specific content of the vocabulary.
[0073] In the embodiment of the present application, a second image description text is obtained by sampling a vocabulary based on the first image description text through an image description text expansion model. The vocabulary includes multiple words. When sampling from the vocabulary, the terminal can determine sampling parameters for the multiple words in the vocabulary based on the first image description text. The sampling parameters represent the probability of a word being sampled as a word in the second image description text. Based on the sampling parameters of the multiple words in the vocabulary, the vocabulary is sampled to obtain the second image description text.
[0074] In this embodiment, an image is generated based on the expanded second image description text. To ensure that the image generated based on the second image description text conforms to the first image description text, the second image description text needs to be semantically associated with the first image description text. Therefore, the sampling parameters of the words in the vocabulary can be determined based on the correlation between the words and the first image description text. The higher the correlation between the words and the first image description text, the higher the probability that the word will be sampled as a word in the second image description text.
[0075] In one possible implementation, the sampling parameters of the words in the vocabulary are determined based on the first picture description text through the picture description text expansion model, including: determining the relevance parameter of the words in the vocabulary, which is used to represent the degree of semantic relevance between the words and the first picture description text; and determining the sampling parameters of the words in the vocabulary based on the relevance parameter of the words in the vocabulary.
[0076] Among them, when the terminal determines the sampling parameters of the words in the vocabulary based on the correlation parameters of the words in the vocabulary, the correlation parameters of the words can be directly determined as the sampling parameters of the words, or the correlation parameters of the words can be calculated to obtain the sampling parameters of the words, or the sampling parameters of the words can be determined based on the correlation parameters of the words and other parameters. Other parameters of the words can be co-occurrence parameters, etc., which are not limited in the embodiments of the present application. Co-occurrence parameters refer to parameters that characterize the probability of multiple words appearing together in a document or a text.
[0077] In another possible implementation, in order to make the expanded second picture description text have rich description objects, so that the generated picture has rich content and beautiful background, and the different description objects included are compatible in the same picture, the sampling parameters of the corresponding words in the vocabulary can be increased based on the respective standard picture description texts and simplified picture description texts of multiple reference pictures, so that when the terminal includes a word in the simplified picture description text in the first picture description text, the expanded second picture description text includes the word in the corresponding standard picture description text. Optionally, the sampling parameters of the words in the vocabulary are determined by the picture description text expansion model, including: determining the relevance parameter of the words in the vocabulary by the picture description text expansion model, the relevance parameter is used to indicate the degree of semantic relevance between the word and the first picture description text; obtaining a description word pair, the description word pair including the first word in the simplified picture description text and the second word in the corresponding standard picture description text pair; determining the sampling parameters of the words in the vocabulary by the picture description text expansion model based on the co-occurrence parameter of the description word pair and the relevance parameter of the words in the vocabulary, the co-occurrence parameter is used to indicate the probability that the corresponding standard picture description text includes the second word when the simplified picture description text includes the first word.
[0078] In some embodiments, the standardized picture description text is a picture description text obtained by word expansion of the simplified picture description text. Optionally, the picture description text input by the user is obtained as the simplified picture description text, and the simplified picture description text is word expanded by professionals to obtain the standardized picture description text.
[0079] In other embodiments, the simplified picture description text is obtained by extracting keywords from the standard picture description text. Optionally, the description of the picture on the Internet is obtained as the standard picture description text, and the keyword extraction is performed on the standard picture description text, and the extracted keywords are used as the simplified picture description text.
[0080] Among them, when the description of the picture on the network is obtained as a standard picture description text, pictures that meet the picture quality conditions can be screened out from the network, and the description of the picture that meets the picture quality conditions can be obtained as a standard picture description text, which indirectly ensures the quality of the standard picture description text. Alternatively, filtering conditions can be set for the standard picture description text, and the picture description text that meets the description quality conditions on the network can be obtained as the standard picture description text. Of course, when screening the standard picture description text, it can be manually screened by technical personnel, or certain screening conditions can be set (such as the number of words reaches a specified number, etc.) for automatic screening. The quality conditions may include conditions of at least one dimension such as size, clarity, color or style. It should be noted that the embodiment of the present application does not limit the method of obtaining simple picture description text and standard picture description text.
[0081] The co-occurrence parameters of the descriptive word pairs are used to represent the probability that when the concise picture description text includes the first word, the corresponding standard picture description text includes the second word. In some embodiments, the greater the value of the contribution parameter, the greater the probability. Therefore, the co-occurrence parameters of the descriptive word pairs can be obtained by counting the concise picture description text and the standard picture description text. In some embodiments, the method further includes: counting the words in the standard picture description text and the words in the concise picture description text of each of the multiple reference pictures to obtain multiple descriptive word pairs and the co-occurrence parameters of the multiple descriptive word pairs.
[0082] Optionally, statistics are collected on words in the canonical image description texts and words in the simplified image description texts of each of the multiple reference images to obtain multiple descriptive word pairs and co-occurrence parameters of the multiple descriptive word pairs, including: determining the co-occurrence parameter of the descriptive word pair as the ratio of the number of times the second word appears in a specified canonical image description text to the total number of words in the specified canonical image description text. The specified canonical image description text is the canonical image description text corresponding to the simplified image description text containing the first word.
[0083] For example, if a first word is included in both simplified picture description text 1 and simplified picture description text 2, the number of occurrences of a second word in both standard picture description text 1 and standard picture description text 2 is determined, and the co-occurrence probability of the descriptive word pair of the first word and the second word is determined as the ratio of the number of occurrences to the total number of words in standard picture description text 1 and standard picture description text 2. Standard picture description text 1 is the standard picture description text corresponding to simplified picture description text 1, and standard picture description text 2 is the standard picture description text corresponding to simplified picture description text 2.
[0084] It should be noted that if the co-occurrence parameter of a descriptive word pair is small, the impact on the sampling parameters of the word will also be small. In order to save computing power, when determining the sampling parameters of the words in the vocabulary, the descriptive word pairs with smaller co-occurrence parameters can be ignored. Optionally, the method also includes: based on the co-occurrence parameter threshold, screening multiple descriptive word pairs, retaining the descriptive word pairs whose co-occurrence parameters are not less than the co-occurrence parameter threshold. The co-occurrence parameter threshold can be any value. Optionally, the co-occurrence parameter threshold is an empirical value, or a value set by a technician, etc. The embodiment of the present application does not limit the co-occurrence parameter threshold.
[0085] In some embodiments, determining a sampling parameter for a word in a vocabulary based on co-occurrence parameters of description word pairs and correlation parameters of the words in the vocabulary using an image description text expansion model includes: determining the sampling parameter for the word as the sum of the co-occurrence parameters and the correlation parameters of the words using the image description text expansion model; or performing a weighted summation of the co-occurrence parameters and the correlation parameters of the words to obtain the sampling parameter for the word. The value of the sampling parameter may be positively correlated with the value of the co-occurrence parameter, i.e., a larger co-occurrence parameter corresponds to a larger sampling parameter, and a smaller co-occurrence parameter corresponds to a smaller sampling parameter.
[0086] For example, the co-occurrence parameter between word A in the first image description and word B in the vocabulary is expressed as P_adj[A, B], and the correlation parameter between word A and word B is expressed as softmax[A, B]. Then, the sampling parameter of word B is expressed as softmax[A, B] + a*P_adj[A, B]. Where a is the weight of the co-occurrence parameter. The weight is any value between 0 and 1, for example, 0.3, 0.5, etc.
[0087] It should be noted that when determining the sampling parameters of words in the vocabulary based on the co-occurrence parameters describing the word pairs and the correlation parameters of the words in the vocabulary, in order to avoid the sampling probability represented by the sampling parameters exceeding 1, after determining the sampling parameters, the determined sampling parameters can also be normalized so that the sampling probability represented by the sampling parameters does not exceed 1.
[0088] 303. The terminal samples the vocabulary based on sampling parameters of words in the vocabulary through the picture description text expansion model to obtain a second picture description text.
[0089] The sampling parameter of a word is used to indicate the probability of the word being sampled as a word in the second image description text. Therefore, the terminal sampling the word list based on the sampling parameters of the words in the word list to obtain the second image description text may include: the terminal selecting, based on the sampling parameters of the words in the word list, the word with the largest sampling parameter as the word in the second image description text.
[0090] In order to ensure the richness of the second picture description text, the number of words in the second picture description text can also be set. The terminal samples the vocabulary based on the sampling parameters of the words in the vocabulary through the picture description text expansion model, and samples a corresponding number of words to obtain the second picture description text. In a possible implementation method, the terminal samples multiple words at a time to obtain the second picture description text. The terminal samples the vocabulary based on the sampling parameters of the words in the vocabulary through the picture description text expansion model to obtain the second picture description text, including: the terminal uses the picture description text expansion model based on the sampling parameters of the words in the vocabulary to sample the target number of words with the largest sampling parameters as the words in the second picture description text. The target number is the number of words in the second picture description text.
[0091] In another possible implementation, the terminal samples one word at a time through the picture description text expansion model, and obtains the second picture description text through multiple sampling. The terminal samples the vocabulary based on the sampling parameters of the words in the vocabulary through the picture description text expansion model to obtain the second picture description text, including: the terminal uses the picture description text expansion model to use the sampling parameters of the words in the vocabulary as the words in the second picture description text; the terminal uses the picture description text expansion model to re-determine the sampling parameters of other words in the vocabulary except the sampled words based on the first picture description text and the sampled words, and uses the word with the largest sampling parameter as the word in the second picture description text. The terminal repeatedly performs the steps of re-determining the sampling parameters of other words in the vocabulary except the sampled words based on the first picture description text and the sampled words, and using the word with the largest sampling parameter as the word in the second picture description text, until the number of words in the second picture description text reaches the target number.
[0092] It should be noted that the embodiment of the present application only takes the generation of a second picture description text as an example to exemplify the process of generating the second picture description text. In another embodiment, the terminal can also generate multiple second picture description texts and generate a corresponding picture for each second picture description text.
[0093] Next, the embodiment of the present application provides an exemplary explanation of “expanding the first image description text by using the image description text expansion model to obtain multiple second image description texts”:
[0094] In one possible implementation, a sampling condition can be set so that there are multiple words in the vocabulary that meet the sampling condition. Each time sampling is performed, multiple words that meet the sampling condition are sampled, and each time sampling is performed, the multiple sampled words are used as words in different second image description texts to obtain multiple different second image description texts. The terminal samples the vocabulary based on the sampling parameters of the words in the vocabulary through the image description text expansion model to obtain the second image description text, including: sampling multiple words in the vocabulary whose sampling parameters meet the sampling condition based on the sampling parameters of the words in the vocabulary through the image description text expansion model to obtain multiple second image description texts, and different second image description texts include different words that meet the sampling condition.
[0095] The sampling condition may be that the sampling parameter is not less than a sampling parameter threshold, or that the sampling parameter is one of the largest P sampling parameters among the sampling parameters of multiple words in the vocabulary. The present embodiment does not limit the sampling condition.
[0096] For example, the terminal may sort the words in the vocabulary in descending order of the sampling parameter, select some of the top-ranked words, and sample the vocabulary, thereby obtaining a second image based on the sampled words. Selecting some of the top-ranked words may include selecting a preset number (e.g., P) of consecutive words starting from the first ranked word. That is, the terminal may sample P words with the largest sampling parameters from the vocabulary. P is any value greater than 1.
[0097] The picture description text expansion model can be any natural language generation model, and the embodiments of the present application do not limit the picture description text expansion model. The picture description text expansion model is exemplified by taking the model structure shown in Figure 4 as an example. As shown in Figure 4, the picture description text expansion model includes an encoding layer and a decoding layer. The encoding layer encodes the first picture description text to obtain the features of the first picture description text; the decoding layer decodes the features of the first picture description text to obtain at least one second picture description text; when decoding, the relevance word bag of the picture description text can be referred to, and the relevance word bag includes co-occurrence parameters of multiple description word pairs.
[0098] 304. The terminal obtains multiple random factors, and generates pictures based on the multiple random factors and the second picture description text respectively.
[0099] In an embodiment of the present application, the random factor is used to indicate the initial state of the image to be generated. By obtaining multiple random factors and generating images based on each random factor and the second image description text, multiple different images can be obtained, so that the images generated based on the second image description text have diversity.
[0100] The random factor can be any value, for example, 1, 2, 10, 50, 100, etc., and the embodiment of the present application does not limit the random factor. The terminal can randomly select a value from the target numerical range as a random value. Therefore, the target numerical range can be any numerical range, and the embodiment of the present application does not limit the target numerical range.
[0101] In some embodiments, multiple random factors may also be pre-set, and the embodiment of the present application does not limit the method for obtaining the random factors.
[0102] In one possible implementation, step 304 may be implemented using an image generation model, which may be a diffusion model, such as a stable diffusion (learnable diffusion) 1.4 model.
[0103] For example, the image generation model is shown in Figure 5. A random factor x and an image description are input into the image generation model. The model encodes the random factor into a latent representation space to obtain a latent feature z. It then performs forward diffusion on the latent feature z to obtain a noise feature zT. The image generation model processes the image description and the noise feature zT across attention layers to obtain a processed noise feature zT-1. This noise feature zT-1 incorporates information from the image description. The processed noise feature zT-1 is then denoised to obtain a denoised feature z. This denoised feature z is then decoded to obtain the image.
[0104] It should be noted that the embodiment of the present application only uses the example of generating multiple images based on a second image description text to illustrate the image generation process. In another embodiment, a single image can also be generated based on a second image description text. The embodiment of the present application does not limit the image generation process.
[0105] 305. The terminal sorts the multiple pictures based on at least one of a correlation parameter and a quality parameter of the multiple pictures.
[0106] Among them, the relevance parameter of the picture represents the degree of relevance between the picture and the first picture description text. In the embodiment of the present application, although the picture is generated based on the second picture description text, the generated picture obviously needs to conform to the intention of the first picture description text. Therefore, the terminal sorts the multiple pictures based on the relevance parameters of the multiple pictures, so that the pictures that are more relevant to the first picture description text are placed in front. Taking the example that the first picture description text is the picture description text entered by the user, by sorting the multiple pictures based on the relevance parameters of the multiple pictures, the pictures that are more in line with the user's intention can be placed in front for the user to select.
[0107] It should be noted that the embodiments of the present application do not limit the manner in which the terminal determines the correlation parameters of multiple images. In one possible implementation, the terminal determines the correlation parameter between the first image description text and the image based on the proportion of the object described by the first image description text in the image. In another possible implementation, the terminal processes the first image description text and the image using a correlation model to obtain the correlation parameter of the image.
[0108] The correlation model is a model used to determine the correlation between two pieces of input information. The present embodiment does not limit the model structure of the correlation model. The correlation model can be a model trained based on the first sample information, the second sample information, and the sample correlation, where the sample correlation refers to the correlation between the first sample information and the second sample information.
[0109] For example, the relevance model is shown in Figure 6. The image is first segmented into 6*6=36 small blocks. A fully connected network is then used to construct an embedding representation for each block. Each embedding representation is then fed into a multi-head self-attention layer for self-attention processing. The processed features are then fed into a fully connected layer for deep feature extraction. The first image description text is segmented, and word vectors are obtained for each segmentation result. These multiple word vectors are then fed into a multi-head self-attention layer for self-attention processing. The processed features are then fed into a fully connected layer for deep feature extraction. Afterwards, the image features and image description text features obtained by deep feature extraction are input into the multi-head self-attention layer to obtain the query features, key features and value features of the image description text features. Based on the query features and key features of the image description text features, the weight of the value features is determined. Based on the weight of the value features, the value features are weighted to obtain the features after self-attention processing. The features are input into the fully connected layer for deep feature extraction, and then correlation prediction is performed to obtain the correlation parameters between the image and the first image description text.
[0110] Since the image generation model introduces a random factor when generating images based on the second image description text, the generated images have diversity. In order to avoid poor quality of generated images, the embodiment of the present application can also sort the multiple images based on the quality parameters of the multiple images so that the images with higher quality are placed in front for users to select.
[0111] It should be noted that the embodiments of the present application do not limit the manner in which the terminal determines the quality parameters of multiple images. In one possible implementation, the terminal determines the quality parameters of the images based on at least one of the image's clarity, brightness, and hue. In another possible implementation, the terminal processes the images using a quality assessment model to obtain the image's quality parameters.
[0112] The quality assessment model is a model for assessing image quality. The present embodiment does not limit the model structure of the quality assessment model. The quality assessment model may be a model trained based on sample images and sample quality parameters, where the sample quality parameters are quality parameters of the sample images.
[0113] The embodiment of this application uses the quality assessment model shown in Figure 7 as an example to illustrate the process of processing an image through the quality assessment model. As shown in Figure 7, the image is first segmented into 6*6=36 small blocks, and then an embedding representation of each small block is constructed through a fully connected network. The embedding representation of each small block is input into the multi-head self-attention layer for self-attention processing, and the features after self-attention processing are input into the fully connected layer for deep feature extraction. The obtained features are then input into the quality assessment layer to obtain a quality score.
[0114] In some embodiments, the terminal sorts multiple pictures based on at least one of the correlation parameters and quality parameters of the multiple pictures, including: the terminal determines comprehensive evaluation parameters of the multiple pictures based on the correlation parameters and quality parameters of the multiple pictures; and sorts the multiple pictures based on the comprehensive evaluation parameters of the multiple pictures.
[0115] Optionally, the terminal determines a comprehensive evaluation parameter for the multiple images based on the correlation parameters and quality parameters of the multiple images, including: the terminal determining the sum of the correlation parameters and quality parameters of the images as the comprehensive evaluation parameter for the image; or the terminal performing a weighted summation of the correlation parameters and quality parameters of the images to obtain the comprehensive evaluation parameter for the image. The weights of the correlation parameters and the quality parameters may be the same or different, and are not limited in this embodiment of the present application. In some embodiments, the weight of the correlation parameter is 0.7, and the weight of the quality parameter is 0.3.
[0116] 306. The terminal displays at least one picture based on the arrangement order of the multiple pictures.
[0117] After determining the arrangement order of the multiple pictures, the terminal may select one or more pictures to display based on the arrangement order of the multiple pictures for selection by the user.
[0118] In some embodiments, the terminal displays all of the generated multiple images. Optionally, the terminal displays at least one image based on the arrangement order of the multiple images, including: arranging and displaying the multiple images in the arrangement order of the multiple images.
[0119] In some embodiments, the terminal displays only one picture. Optionally, the terminal displays at least one picture based on the arrangement order of the multiple pictures, including: displaying the picture ranked first.
[0120] In some embodiments, the terminal displays a certain number of images. Optionally, the terminal displays at least one image based on the order in which the images are arranged, including displaying multiple images that are at a target position based on the order in which the images are arranged. The target position can be any position, and the embodiments of the present application do not limit the target position.
[0121] It should be noted that the above steps 305 and 306 are optional solutions, that is, the above steps 305 and 306 may be executed or not, and whether to execute the above steps 305 and 306 may be determined by actual application requirements.
[0122] The embodiment of the present application provides a solution for generating pictures based on text, which first uses a picture description text expansion model to perform text expansion on a first picture description text to obtain a second picture description text, and then generates a picture through the second picture description text. Since the picture description text expansion model is trained based on the standard picture description text and simplified picture description text of multiple reference pictures, and the standard picture description text includes multiple words describing the main description object of the reference picture and at least one word used to describe the secondary description object of the reference picture, and the simplified picture description text is a keyword used to describe the main description object in the standard picture description text, the picture description text expansion model can expand other words describing the main description object based on the keyword describing the main description object, and can also expand words describing the secondary description object, so that the expanded picture description text is rich in content, and the picture generated based on the expanded picture description text is rich in content, thereby improving the quality of picture generation.
[0123] Moreover, when the embodiment of the present application obtains the second image description text by sampling the vocabulary, the co-occurrence parameters of the description word pairs are introduced, which can not only sample words with a high degree of relevance, but also sample words with a high co-occurrence probability, making the sampled words richer, thereby making the content of the generated second image description text richer, and thus making the image quality of the image generated based on the second image description text higher.
[0124] Furthermore, the embodiment of the present application can generate multiple pictures and sort the multiple pictures based on the relevance of the pictures to the first picture description text and the picture quality, so that pictures that are relevant to the first picture description text and have high picture quality are ranked in front, thereby improving the user experience of selecting pictures.
[0125] The embodiment of the present application takes Figure 8 as an example to illustrate the process of generating pictures based on text. As shown in Figure 8, the first picture description text input by the user is first obtained, and the first picture description text is expanded through the picture description text expansion model to obtain multiple second picture description texts. The multiple second picture description texts are respectively input into the picture generation model, and at least one picture is generated for each second picture description text through the picture generation model; each picture is then input into the relevance model and the quality assessment model to determine the relevance parameter and quality parameter of each picture; based on the relevance parameter and quality parameter of each picture, the multiple pictures are sorted.
[0126] FIG9 is a flowchart of a method for training a picture description text expansion model for picture generation provided in an embodiment of the present application. The embodiment of the present application is exemplified by taking a computer device as an example. Referring to FIG9 , the method includes:
[0127] 901. The computer device obtains the description of the image on the network as standard image description text.
[0128] The image on the network can be any image circulated on the Internet. For example, the image is an image on a video website, or it can be an image in any existing database. The embodiments of this application do not limit the images on the network. It should be noted that most images circulated on the Internet are provided with image tags. The image tags are used to describe the image and can be regarded as descriptions of the image. Another point to note is that the image obtained by the computer device from the network can be the reference image in the embodiment shown in Figure 3.
[0129] Optionally, the computer device randomly obtains an image from the network and uses the description of the image as the standard image description text. Optionally, the computer device obtains an image from the network that meets the image quality requirements and uses the description of the image as the standard image description text. Optionally, the computer device obtains an image from the network whose description exceeds the target word count and uses the description of the image as the standard image description text. This embodiment of the application does not limit the method for obtaining the standard image description text.
[0130] 902. The computer device extracts keywords from the standard image description text and uses the extracted keywords as the simplified image description text.
[0131] The computer device can use any keyword extraction method to extract keywords from the standard image description text. The embodiment of this application does not limit the keyword extraction method, and only uses the following embodiment to exemplify the keyword extraction process.
[0132] In some embodiments, a computer device segments the standard image description text, determines the semantic weight of each segmentation result in the standard image description text based on the semantics of each segmentation result and the semantics of the standard image description text, and uses the segmentation result with the highest semantic weight as the simplified image description text.
[0133] It should be noted that in order to ensure the accuracy of the standard picture description text and the simple picture description text, after obtaining the standard picture description text and the simple picture description text, they can also be manually verified or screened.
[0134] 903. The computer device trains a picture description text expansion model based on the standard picture description text and the simplified picture description text. The picture description text expansion model is a model that expands the picture description text used to generate the picture.
[0135] The computer device can input the simplified picture description text into the picture description text expansion model, and the picture description text expansion model expands the words of the simplified picture description text according to the method shown in steps 302 to 303 above to obtain a predicted picture description text; based on the difference between the predicted picture description text and the standard picture description text, the picture description text expansion model is trained to converge the error of the picture description text expansion model.
[0136] It should be noted that the embodiments of the present application can be implemented by at least one of a picture description text expansion model, a picture generation model, a relevance model, and a quality assessment model. Therefore, at least one of the above models can be trained together. For example, a picture is obtained from the network as a sample picture, the description of the picture is used as a standard picture description text, keywords are extracted from the standard picture description text, the extracted keywords are used as a simplified picture description text, and the sample picture is annotated with relevance parameters and quality parameters.
[0137] When training the model, the correspondence between some sample images and standard image description texts, relevance parameters, and quality parameters can be disrupted to form negative samples and improve the training effect of the model.
[0138] The picture description text expansion model training method for image generation provided in the embodiments of this application can automatically obtain standard picture description text from the network and automatically generate concise picture description text based on the standard picture description text, thereby reducing the difficulty of obtaining a sample set and also reducing human and material costs. The picture description text expansion model trained using the picture description text expansion model training method of this embodiment can be used in the method of generating pictures based on text in any of the above embodiments.
[0139] FIG10 is a schematic diagram of a device for generating an image based on text according to an embodiment of the present application. Referring to FIG10 , the device includes:
[0140] An acquisition module 1001 is configured to acquire a first picture description text, where the first picture description text is used to describe the picture content of the picture to be generated;
[0141] An expansion module 1002 is configured to process the first picture description text using a picture description text expansion model to obtain a second picture description text, wherein the picture description text expansion model is trained based on the standard picture description text and the simplified picture description text of each of a plurality of reference pictures, and is configured to expand the simplified picture description text into the corresponding standard picture description text, wherein the standard picture description text includes a plurality of words for describing a primary description object of the reference picture and at least one word for describing a secondary description object of the reference picture, and the simplified picture description text is a keyword in the standard picture description text for describing the primary description object;
[0142] The generating module 1003 is configured to generate a picture based on the second picture description text.
[0143] The embodiment of the present application provides a solution for generating pictures based on text, which first uses a picture description text expansion model to perform text expansion on a first picture description text to obtain a second picture description text, and then generates a picture through the second picture description text. Since the picture description text expansion model is trained based on the standard picture description text and simplified picture description text of multiple reference pictures, and the standard picture description text includes multiple words describing the main description object of the reference picture and at least one word used to describe the secondary description object of the reference picture, and the simplified picture description text is a keyword used to describe the main description object in the standard picture description text, the picture description text expansion model can expand other words describing the main description object based on the keyword describing the main description object, and can also expand words describing the secondary description object, so that the expanded picture description text is rich in content, and the picture generated based on the expanded picture description text is rich in content, thereby improving the quality of picture generation.
[0144] As shown in FIG11 , optionally, the expansion module 1002 includes:
[0145] a parameter determination unit 1012, configured to determine a sampling parameter of a word in the vocabulary using the picture description text expansion model, wherein the sampling parameter is used to represent a probability of a word being sampled as a word in the second picture description text;
[0146] The sampling unit 1022 is configured to sample the vocabulary based on sampling parameters of words in the vocabulary by using the picture description text expansion model to obtain a second picture description text.
[0147] Optionally, the parameter determination unit 1012 is used to determine the relevance parameters of the words in the vocabulary through the picture description text expansion model, the relevance parameters are used to represent the degree of semantic relevance between the words and the first picture description text; obtain a description word pair, the description word pair including a first word in the simplified picture description text and a second word in the corresponding standard picture description text pair; determine the sampling parameters of the words in the vocabulary based on the co-occurrence parameters of the description word pairs and the relevance parameters of the words in the vocabulary through the picture description text expansion model, the co-occurrence parameters are used to represent the probability that the corresponding standard picture description text includes the second word when the simplified picture description text includes the first word.
[0148] Optionally, the device further comprises:
[0149] The statistics module 1004 is configured to perform statistics on the words in the standard picture description text and the words in the simplified picture description text of each of the plurality of reference pictures to obtain a plurality of description word pairs and co-occurrence parameters of the plurality of description word pairs.
[0150] Optionally, the device further comprises:
[0151] The screening module 1005 is configured to screen the plurality of description word pairs based on a co-occurrence parameter threshold, and retain the description word pairs whose co-occurrence parameters are not less than the co-occurrence parameter threshold.
[0152] Optionally, the sampling unit 1022 is configured to obtain, through the image description text expansion model, a plurality of second image description texts based on sampling parameters of words in the vocabulary, sampling multiple words in the vocabulary whose sampling parameters meet the sampling condition, where different second image description texts include different words that meet the sampling condition;
[0153] The generating module 1003 is configured to execute, for each of the plurality of second picture description texts, a step of generating a picture based on the second picture description text.
[0154] Optionally, the expansion module 1002 is configured to perform word expansion on the first picture description text through a picture description text expansion model to obtain a second picture description text, wherein the picture description text expansion model is configured to expand at least one word semantically associated with the input picture description text.
[0155] Optionally, the generating module 1003 includes:
[0156] An acquiring unit 1013 is configured to acquire a plurality of random factors, where the random factors are used to indicate an initial state of a to-be-generated image;
[0157] The generating unit 1023 is configured to generate a picture based on the random factors and the second picture description text for each of the multiple random factors.
[0158] Optionally, there are multiple pictures; the device further includes:
[0159] a sorting module 1006, configured to sort the multiple images based on at least one of a relevance parameter and a quality parameter of the multiple images;
[0160] The display module 1007 is configured to display at least one picture based on the arrangement order of the multiple pictures.
[0161] Optionally, the display module 1007 is configured to display the multiple pictures in an arrangement order; or
[0162] Display module 1007, used to display the picture ranked first; or
[0163] The display module 1007 is configured to display the plurality of pictures at the front target positions based on the arrangement order of the plurality of pictures.
[0164] It should be noted that the apparatus for generating images based on text provided in the above embodiment is only illustrated by the division of the above functional modules. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the terminal can be divided into different functional modules to complete all or part of the functions described above. In addition, the apparatus for generating images based on text provided in the above embodiment and the method embodiment for generating images based on text are of the same concept. The specific implementation process is detailed in the method embodiment and will not be repeated here.
[0165] FIG12 is a schematic diagram of the structure of a device for training a picture description text expansion model for picture generation provided by an embodiment of the present application. Referring to FIG12 , the device includes:
[0166] The acquisition module 1201 is used to obtain the description of the picture on the Internet as a standard picture description text;
[0167] Extraction module 1202, configured to extract keywords from the standard image description text and use the extracted keywords as a simplified image description text;
[0168] The training module 1203 is used to train a picture description text expansion model based on the standard picture description text and the simplified picture description text. The picture description text expansion model is a model for expanding the picture description text used to generate pictures.
[0169] The picture description text expansion model training scheme for picture generation provided in the embodiment of the present application can automatically obtain standard picture description text from the network, and automatically generate simple picture description text based on the standard picture description text, thereby reducing the difficulty of obtaining sample sets and reducing labor and material costs.
[0170] In some embodiments, the computer device is provided as a terminal. The terminal includes a processor and a memory, wherein the memory stores at least one computer-readable instruction, which is loaded and executed by the processor to implement the operations performed in the method for generating an image based on text in the above embodiment, or the operations performed in the method for training an image description text expansion model for image generation in the above embodiment.
[0171] FIG13 shows a schematic structural diagram of a terminal 1300 provided in an exemplary embodiment of the present application.
[0172] The terminal 1300 includes a processor 1301 and a memory 1302 .
[0173] The processor 1301 may include one or more processing cores, such as a 4-core processor, an 8-core processor, etc. The processor 1301 may be implemented in at least one hardware form of DSP (Digital Signal Processing), FPGA (Field Programmable Gate Array), or PLA (Programmable Logic Array). The processor 1301 may also include a main processor and a coprocessor. The main processor is a processor for processing data in the awake state, also known as a CPU (Central Processing Unit); the coprocessor is a low-power processor for processing data in the standby state. In some embodiments, the processor 1301 may be integrated with a GPU (Graphics Processing Unit), which is responsible for rendering and drawing the content to be displayed on the display screen. In some embodiments, the processor 1301 may also include an AI (Artificial Intelligence) processor, which is used to process computing operations related to machine learning.
[0174] The memory 1302 may include one or more computer-readable storage media, which may be non-transitory. The memory 1302 may also include a high-speed random access memory, and a non-volatile memory, such as one or more disk storage devices, flash memory storage devices. In some embodiments, the non-transitory computer-readable storage medium in the memory 1302 is used to store at least one computer-readable instruction, which is used by the processor 1301 to implement the method for generating an image based on text provided in the method embodiment of the present application or the image description text expansion model training method for image generation.
[0175] In some embodiments, terminal 1300 may optionally include a peripheral device interface 1303 and at least one peripheral device. Processor 1301, memory 1302, and peripheral device interface 1303 may be connected via a bus or signal lines. Each peripheral device may be connected to peripheral device interface 1303 via a bus, signal lines, or circuit boards. Optionally, the peripheral device includes at least one of a radio frequency circuit 1304, a display screen 1305, a camera assembly 1306, an audio circuit 1307, and a power supply 1308.
[0176] The peripheral device interface 1303 can be used to connect at least one I / O (Input / Output)-related peripheral device to the processor 1301 and the memory 1302. In some embodiments, the processor 1301, the memory 1302, and the peripheral device interface 1303 are integrated on the same chip or circuit board; in some other embodiments, any one or two of the processor 1301, the memory 1302, and the peripheral device interface 1303 can be implemented on separate chips or circuit boards, which is not limited in this embodiment.
[0177] The RF circuit 1304 is used to receive and transmit RF (Radio Frequency) signals, also known as electromagnetic signals. The RF circuit 1304 communicates with communication networks and other communication devices via electromagnetic signals. The RF circuit 1304 converts electrical signals into electromagnetic signals for transmission, or converts received electromagnetic signals into electrical signals. Optionally, the RF circuit 1304 includes an antenna system, an RF transceiver, one or more amplifiers, a tuner, an oscillator, a digital signal processor, a codec chipset, a user identity module card, and the like. The RF circuit 1304 can communicate with other devices via at least one wireless communication protocol. Such wireless communication protocols include, but are not limited to, metropolitan area networks, various generations of mobile communication networks (2G, 3G, 4G, and 5G), wireless local area networks, and / or WiFi (Wireless Fidelity) networks. In some embodiments, the RF circuit 1304 may also include circuits related to Near Field Communication (NFC), which is not limited in this application.
[0178] The display screen 1305 is used to display a UI (User Interface). The UI may include graphics, text, icons, videos, and any combination thereof. When the display screen 1305 is a touch screen display, the display screen 1305 also has the ability to collect touch signals on the surface or above the surface of the display screen 1305. The touch signal can be input as a control signal to the processor 1301 for processing. At this time, the display screen 1305 can also be used to provide virtual buttons and / or virtual keyboards, also known as soft buttons and / or soft keyboards. In some embodiments, there can be one display screen 1305, which is set on the front panel of the terminal 1300; in other embodiments, there can be at least two display screens 1305, which are respectively set on different surfaces of the terminal 1300 or in a folding design; in other embodiments, the display screen 1305 can be a flexible display screen, which is set on the curved surface or folding surface of the terminal 1300. Even more, the display screen 1305 can be set to a non-rectangular irregular shape, that is, a special-shaped screen. The display screen 1305 can be made of materials such as LCD (Liquid Crystal Display) and OLED (Organic Light-Emitting Diode).
[0179] The camera assembly 1306 is used to capture images or videos. Optionally, the camera assembly 1306 includes a front camera and a rear camera. The front camera is arranged on the front panel of the terminal 1300, and the rear camera is arranged on the back of the terminal 1300. In some embodiments, there are at least two rear cameras, which are any one of a main camera, a depth of field camera, a wide-angle camera, and a telephoto camera, so as to realize the fusion of the main camera and the depth of field camera to realize the background blur function, the fusion of the main camera and the wide-angle camera to realize panoramic shooting and VR (Virtual Reality) shooting function or other fusion shooting functions. In some embodiments, the camera assembly 1306 may also include a flash. The flash can be a single-color temperature flash or a dual-color temperature flash. The dual-color temperature flash refers to a combination of a warm light flash and a cold light flash, which can be used for light compensation at different color temperatures.
[0180] The audio circuit 1307 may include a microphone and a speaker. The microphone is used to collect sound waves from the user and the environment, and convert the sound waves into electrical signals that are input into the processor 1301 for processing, or input into the radio frequency circuit 1304 to achieve voice communication. For the purpose of stereo sound collection or noise reduction, there may be multiple microphones, each located in different parts of the terminal 1300. The microphone may also be an array microphone or an omnidirectional collection microphone. The speaker is used to convert electrical signals from the processor 1301 or the radio frequency circuit 1304 into sound waves. The speaker may be a traditional thin film speaker or a piezoelectric ceramic speaker. When the speaker is a piezoelectric ceramic speaker, it can not only convert electrical signals into sound waves audible to humans, but also convert electrical signals into sound waves inaudible to humans for purposes such as ranging. In some embodiments, the audio circuit 1307 may also include a headphone jack.
[0181] Power supply 1308 is used to power various components in terminal 1300. Power supply 1308 can be AC power, DC power, a disposable battery, or a rechargeable battery. When power supply 1308 includes a rechargeable battery, the rechargeable battery can support wired charging or wireless charging. The rechargeable battery can also be used to support fast charging technology.
[0182] In some embodiments, the terminal 1300 further includes one or more sensors 1309 , including but not limited to: an acceleration sensor 1310 , a gyroscope sensor 1311 , a pressure sensor 1312 , an optical sensor 1313 , and a proximity sensor 1314 .
[0183] The accelerometer 1310 can detect the magnitude of acceleration along the three coordinate axes of the coordinate system established by the terminal 1300. For example, the accelerometer 1310 can be used to detect the components of gravity acceleration along the three coordinate axes. The processor 1301 can control the display screen 1305 to display the user interface in either a landscape or portrait view based on the gravity acceleration signal collected by the accelerometer 1310. The accelerometer 1310 can also be used to collect game or user motion data.
[0184] The gyroscope sensor 1311 can detect the orientation and rotation angle of the terminal 1300. It can also work with the accelerometer 1310 to collect the user's 3D movements on the terminal 1300. Based on the data collected by the gyroscope sensor 1311, the processor 1301 can implement the following functions: motion sensing (for example, changing the UI based on the user's tilt operation), image stabilization during shooting, game control, and inertial navigation.
[0185] The pressure sensor 1312 can be provided on the side frame of the terminal 1300 and / or below the display screen 1305. When the pressure sensor 1312 is provided on the side frame of the terminal 1300, it can detect the user's gripping signal of the terminal 1300. The processor 1301 then performs left-hand or right-hand recognition or shortcut operations based on the gripping signal collected by the pressure sensor 1312. When the pressure sensor 1312 is provided below the display screen 1305, the processor 1301 controls the operable controls on the UI interface based on the user's pressure operation on the display screen 1305. Operable controls include at least one of a button control, a scroll bar control, an icon control, and a menu control.
[0186] Optical sensor 1313 is used to detect ambient light intensity. In one embodiment, processor 1301 can control the display brightness of display screen 1305 based on the ambient light intensity detected by optical sensor 1313. Optionally, when the ambient light intensity is high, the display brightness of display screen 1305 is increased; when the ambient light intensity is low, the display brightness of display screen 1305 is decreased. In another embodiment, processor 1301 can also dynamically adjust the shooting parameters of camera assembly 1306 based on the ambient light intensity detected by optical sensor 1313.
[0187] Proximity sensor 1314, also known as a distance sensor, is provided on the front panel of terminal 1300. Proximity sensor 1314 is used to detect the distance between the user and the front of terminal 1300. In one embodiment, when proximity sensor 1314 detects that the distance between the user and the front of terminal 1300 is gradually decreasing, processor 1301 controls display screen 1305 to switch from the screen-on state to the screen-off state. When proximity sensor 1314 detects that the distance between the user and the front of terminal 1300 is gradually increasing, processor 1301 controls display screen 1305 to switch from the screen-off state to the screen-on state.
[0188] Those skilled in the art will understand that the structure shown in FIG13 does not constitute a limitation on the terminal 1300 , and the terminal 1300 may include more or fewer components than shown in the figure, or combine certain components, or adopt a different component arrangement.
[0189] In some embodiments, the computer device is provided as a server. The server includes a processor and a memory, wherein the memory stores at least one computer-readable instruction, which is loaded and executed by the processor to implement the operations performed in the method for generating an image based on text in the above embodiment, or the operations performed in the method for training an image description text expansion model for image generation in the above embodiment.
[0190] FIG14 is a schematic diagram of the structure of a server provided in an embodiment of the present application. The server 1400 may vary significantly due to different configurations or performances, and may include one or more processors (Central Processing Units, CPUs) 1401 and one or more memories 1402. The memories 1402 store at least one program code, which is loaded and executed by the processor 1401 to implement the methods provided in the above-mentioned various method embodiments. Of course, the server may also have components such as a wired or wireless network interface, a keyboard, and an input / output interface for input and output. The server may also include other components for implementing device functions, which will not be described in detail here.
[0191] The server 1400 is used to execute the steps executed by the server in the above method embodiment.
[0192] An embodiment of the present application also provides a computer-readable storage medium, which stores at least one computer-readable instruction, and the at least one computer-readable instruction is loaded and executed by a processor to implement the operations performed in the method of generating an image based on text in the above embodiment, or to implement the operations performed in the method of training an image description text expansion model for image generation in the above embodiment.
[0193] An embodiment of the present application also provides a computer program product, including computer-readable instructions, which are loaded and executed by a processor to implement the operations performed in the method for generating an image based on text in the above embodiment, or to implement the operations performed in the method for training an image description text expansion model for image generation in the above embodiment.
[0194] Those skilled in the art will understand that all or part of the steps to implement the above embodiments may be accomplished by hardware, or by a program to instruct the relevant hardware, and the program may be stored in a computer-readable storage medium, which may be a read-only memory, a disk, or an optical disk, etc.
[0195] The technical features of the above embodiments can be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0196] The above-described embodiments merely represent several implementation methods of the present application. While the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the present invention. It should be noted that a person skilled in the art could make various modifications and improvements without departing from the spirit of the present application, all of which fall within the scope of protection of the present application. Therefore, the scope of protection of the present patent application shall be determined by the appended claims.
Claims
1. A method for generating a picture based on text, the method comprising: Obtaining a first picture description text, where the first picture description text is used to describe the picture content of the picture to be generated; Performing text expansion on the first picture description text to obtain a second picture description text through a picture description text expansion model, wherein the picture description text expansion model is obtained based on training of respective standard picture description texts and simplified picture description texts of a plurality of reference pictures, and is used to expand the simplified picture description text into the corresponding standard picture description text, wherein the standard picture description text includes a plurality of words for describing a primary description object of the reference picture and at least one word for describing a secondary description object of the reference picture, and the simplified picture description text is a keyword in the standard picture description text for describing the primary description object; and Generate a picture based on the second picture description text.
2. According to the method of claim 1, the step of performing text expansion on the first picture description text by using a picture description text expansion model to obtain a second picture description text comprises: Determining a sampling parameter of a word in a vocabulary by using the picture description text expansion model, wherein the sampling parameter is used to indicate a probability that the word is sampled as a word in the second picture description text; The picture description text expansion model is used to sample the vocabulary based on sampling parameters of words in the vocabulary to obtain the second picture description text.
3. The method according to claim 2, wherein determining the sampling parameters of the words in the vocabulary through the picture description text expansion model comprises: Determining, by means of the picture description text expansion model, a relevance parameter of a word in the vocabulary, wherein the relevance parameter is used to indicate a semantic relevance between the word and the first picture description text; Acquire a description word pair, wherein the description word pair includes a first word in the simplified picture description text and a second word in the corresponding standard picture description text pair; The sampling parameters of the words in the vocabulary are determined through the picture description text expansion model based on the co-occurrence parameters of the description word pairs and the correlation parameters of the words in the vocabulary, and the co-occurrence parameters are used to represent the probability that the standard picture description text includes the second word when the simplified picture description text includes the first word.
4. The method according to claim 3, further comprising: The words in the standard picture description text and the words in the simplified picture description text of each of the multiple reference pictures are counted to obtain multiple description word pairs and co-occurrence parameters of the multiple description word pairs.
5. The method according to claim 4, further comprising: Based on the co-occurrence parameter threshold, the plurality of description word pairs are screened, and description word pairs having co-occurrence parameters not less than the co-occurrence parameter threshold are retained.
6. The method according to any one of claims 2 to 5, wherein the step of sampling the vocabulary based on sampling parameters of words in the vocabulary through the picture description text expansion model to obtain the second picture description text comprises: By using the picture description text expansion model, based on the sampling parameters of the words in the vocabulary, multiple words in the vocabulary whose sampling parameters meet the sampling conditions are sampled to obtain multiple second picture description texts, where different second picture description texts include different words that meet the sampling conditions; The method further comprises: For the multiple second picture description texts, the step of generating pictures based on the second picture description texts is performed respectively.
7. The method according to any one of claims 1 to 6, wherein generating a picture based on the second picture description text comprises: Acquire multiple random factors, where the random factors are used to indicate an initial state of a to-be-generated image; For the multiple random factors, pictures are generated based on the random factors and the second picture description text respectively.
8. The method according to any one of claims 1 to 7, wherein the number of the pictures is multiple; the method further comprising: sorting the multiple pictures based on at least one of a relevance parameter and a quality parameter of the multiple pictures, wherein the relevance parameter of the pictures is used to indicate a relevance degree between the pictures and the first picture description text; At least one picture is displayed based on the arrangement order of the multiple pictures.
9. The method according to claim 8, wherein displaying at least one picture based on the arrangement order of the plurality of pictures comprises: Arrange and display the multiple pictures according to the arrangement order of the multiple pictures; or, Display the picture ranked first; or, Based on the arrangement order of the plurality of pictures, a plurality of pictures at a front target position are displayed.
10. A method for training a picture description text expansion model for picture generation, the method comprising: Obtain the description of the picture on the Internet as a standard picture description text; Extracting keywords from the standard picture description text, and using the extracted keywords as a concise picture description text; and Based on the standard picture description text and the simplified picture description text, a picture description text extension model is trained, where the picture description text extension model is a model for extending the picture description text used to generate pictures.
11. A device for generating a picture based on text, the device comprising: An acquisition module, used to acquire a first picture description text, where the first picture description text is used to describe the picture content of the picture to be generated; an expansion module, configured to perform text expansion on the first picture description text through a picture description text expansion model to obtain a second picture description text, wherein the picture description text expansion model is obtained by training based on the respective standard picture description texts and simplified picture description texts of a plurality of reference pictures, and is configured to expand the simplified picture description text into the corresponding standard picture description text, wherein the standard picture description text includes a plurality of words for describing a primary description object of the reference picture and at least one word for describing a secondary description object of the reference picture, and the simplified picture description text is a keyword in the standard picture description text for describing the primary description object; and A generating module is used to generate a picture based on the second picture description text.
12. A device for training a picture description text expansion model for picture generation, the device comprising: An acquisition module is used to obtain the description of the picture on the network as a standard picture description text; An extraction module, used to extract keywords from the standard picture description text and use the extracted keywords as a simplified picture description text; and A training module is used to train a picture description text extension model based on the standard picture description text and the simplified picture description text. The picture description text extension model is a model for extending the picture description text used to generate pictures.
13. A computer device, comprising a processor and a memory, wherein the memory stores at least one computer-readable instruction, and the at least one computer-readable instruction is loaded and executed by the processor to implement the method according to any one of claims 1 to 10.
14. A computer-readable storage medium, wherein at least one computer-readable instruction is stored in the computer-readable storage medium, and the at least one computer-readable instruction is loaded and executed by a processor to implement the method according to any one of claims 1 to 10.
15. A computer program product, comprising computer readable instructions, wherein the computer readable instructions are loaded and executed by a processor to implement the method according to any one of claims 1 to 10.
Citation Information
Patent Citations
Description text generation model training method and device
CN110362823A
Method and device for generating graphic mark, electronic equipment and storage medium
CN113836933A
Method and device for generating image based on text, electronic equipment and medium
CN115631251A
Character-based picture generation method and device, equipment and storage medium
CN116955677A
Methods and systems for expanding vocabulary
US20230047665A1
