Target Chinese poster generation method, device, computer equipment and storage medium
By combining a large language model and a text-to-image model, an improved generative adversarial network is used to predict Chinese layout and automatically generate target Chinese posters, solving the problems of low efficiency and poor quality of traditional manual generation, and achieving efficient and intelligent poster generation. and dissemination.
Patent Information
- Application Number
- CN202410844590.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-27
- Publication Date
- 2024-10-11
- Estimated Expiration
- 2044-06-27
AI Technical Summary
The traditional manual generation of targeted Chinese posters is inefficient and of poor quality, making it difficult to meet the rapidly growing market demand for high-quality posters, resulting in low information dissemination efficiency.
A large language model is used to identify and classify the poster prompt text input by the user, and the text-to-image model is combined to generate the poster background image. The improved generative adversarial network model is used to predict Chinese layout and generate layout information, and automatically create the target Chinese poster.
It achieves rapid and intelligent generation of high-quality target Chinese posters, improves poster generation efficiency and information dissemination efficiency, and reduces manual intervention.
Smart Images

Figure CN118397148B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image processing technology, and in particular to a method, device, computer equipment and storage medium for generating a target Chinese poster. Background Art
[0002] In Internet commercial services, the influence of artistic posters is an important means of network influence. Posters, as an intuitive information carrier, can be used to promote and disseminate relevant information about corporate products to achieve the purpose of increasing product attractiveness.
[0003] Due to the complexity of the target Chinese poster characters, existing machine learning algorithms find it difficult to generate Chinese art posters with visually attractive backgrounds and Chinese text. Therefore, traditional methods of generating target Chinese posters usually rely on manual generation, such as designers manually selecting the poster background image, laying out product images and text in the poster, and manually modifying the poster text style.
[0004] The traditional generation of target Chinese posters requires a lot of manual time, which makes the generation efficiency of target Chinese posters low, and the effect design of target Chinese posters depends on the experience of designers, which is difficult to meet the rapidly growing demand for high-quality target Chinese posters in the market, resulting in low efficiency of information dissemination. Therefore, there is an urgent need for a method to automatically create a target Chinese poster based on the prompt text entered by the user, which can take into account the generation efficiency and quality of the target Chinese poster to improve the information dissemination efficiency of the target Chinese poster. Summary of the invention
[0005] The present invention provides a method, device, computer equipment and storage medium for generating a target Chinese poster, so as to solve the problem that the poster generation efficiency is low and the quality of the target Chinese poster is poor, resulting in poor efficiency of information dissemination in the traditional method of manually generating a target Chinese poster.
[0006] A method for generating a target Chinese poster is provided, comprising:
[0007] A large language model is used to identify and classify the poster prompt text input by the user to obtain the background description text and the displayed Chinese text;
[0008] The text-to-image model is used to generate an image from the background description text to obtain the poster background image;
[0009] Based on the poster background image and the displayed Chinese text, a preset Chinese layout model is used to perform text layout in the poster background image to obtain Chinese layout information of the displayed Chinese text. The preset Chinese layout model is a neural network model obtained by training multiple Chinese sample posters after improving the generative adversarial network;
[0010] The poster is generated based on the Chinese layout information, the displayed Chinese text and the poster background image to obtain the target Chinese poster.
[0011] Optionally, based on the poster background image and the displayed Chinese text, a preset Chinese layout model is used to perform text layout in the poster background image to obtain Chinese layout information of the displayed Chinese text, including:
[0012] Extracting attribute information of the displayed Chinese text to obtain text attribute information of the displayed Chinese text;
[0013] Based on the poster background image and text attribute information, a preset Chinese layout model is used to predict the layout position of the displayed Chinese text on the poster background image to obtain Chinese layout information.
[0014] Optionally, attribute information is extracted from the displayed Chinese text to obtain text attribute information of the displayed Chinese text, including:
[0015] Determine the number of Chinese text lines contained in the displayed Chinese text, and obtain the number of text lines of the displayed Chinese text;
[0016] According to the characters of the Chinese text line, the length and width ratio of the Chinese text line is determined to obtain the text line size ratio of the Chinese text line. The text attribute information includes the number of text lines displaying Chinese text and the text line size ratio.
[0017] Optionally, the preset Chinese layout model includes a text attribute encoding layer, an image encoding layer, a fusion layer, a generation layer and a recognition layer. Based on the poster background image and text attribute information, the preset Chinese layout model is used to predict the layout position of the displayed Chinese text on the poster background image to obtain Chinese layout information, including:
[0018] The text attribute information is encoded through the text attribute encoding layer to obtain an attribute encoding vector for displaying the Chinese text, and the poster background image is encoded through the image encoding layer to obtain an image encoding vector for the poster background image;
[0019] The attribute coding vector and the image coding vector are fused through the fusion layer to obtain the target fusion vector, and the text layout prediction and image generation of the target fusion vector are performed through the generation layer to obtain the Chinese layout image;
[0020] The text position of the Chinese layout image is recognized through the recognition layer to obtain Chinese layout information showing the Chinese text.
[0021] Optionally, the text attribute information includes the number of text lines and the text line size ratio of the displayed Chinese text, and the attribute encoding vector includes the text line number vector and the size ratio vector. The text attribute information is encoded by the text encoding layer to obtain the attribute encoding vector for displaying the Chinese text, including:
[0022] The number of text lines is encoded by the number encoder of the text encoding layer to obtain a text line number vector;
[0023] The text line size ratio is proportionally encoded through the proportional encoder of the text encoding layer to obtain a size ratio vector.
[0024] Optionally, generating a poster based on the Chinese layout information, the displayed Chinese text and the poster background image to obtain a target Chinese poster includes:
[0025] Using the preset style transfer model, the style of the displayed Chinese text is transferred and converted based on the poster background image to generate the target Chinese graphic for displaying the Chinese text;
[0026] Based on the Chinese layout information, the target Chinese graphic and the poster background image are fused to obtain the target Chinese poster.
[0027] Optionally, the preset Chinese layout model is trained in the following way:
[0028] Acquire multiple Chinese sample posters, and pre-process the multiple Chinese sample posters respectively to obtain a background sample image, a Chinese sample text, and a standard layout position of the Chinese sample text in the background sample image of each Chinese sample poster;
[0029] The background sample image of the Chinese sample poster and the standard attribute information of the Chinese sample text are input into the pre-trained network for text layout prediction, and the predicted layout position of the Chinese sample text in the background sample image is obtained. The pre-trained network is a neural network obtained by adding a text attribute encoding layer to the generative adversarial network;
[0030] Determine the total loss value according to the predicted layout position and the standard layout position;
[0031] When the total loss value does not meet the convergence condition, continue to iterate the parameters of the pre-trained network based on multiple Chinese sample posters until the total loss value meets the convergence condition, determine that the pre-trained network converges, and output the converged pre-trained network as the preset Chinese layout model.
[0032] Provided is a target Chinese poster generation device, comprising:
[0033] The text recognition module is used to use a large language model to recognize and classify the poster prompt text input by the user to obtain the background description text and the display Chinese text;
[0034] An image generation module, used to generate an image from the background description text using a text-to-image model to obtain a poster background image;
[0035] The Chinese layout module is used to perform text layout in the poster background image based on the poster background image and the displayed Chinese text using a preset Chinese layout model to obtain Chinese layout information for the displayed Chinese text. The preset Chinese layout model is a neural network model obtained by training multiple Chinese sample posters after improving the generative adversarial network;
[0036] The poster generation module is used to generate a poster based on Chinese layout information, displayed Chinese text and poster background image to obtain a target Chinese poster.
[0037] A computer device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps of a method for generating a Chinese poster for a listing target are implemented.
[0038] A computer-readable storage medium is provided, which stores a computer program. When the computer program is executed by a processor, the steps of the above-mentioned target Chinese poster generation method are implemented.
[0039] In a solution provided by the above-mentioned target Chinese poster generation method, device, computer equipment and storage medium, a large language model is used to identify and classify the poster prompt text input by the user to obtain background description text and display Chinese text, and a text-to-image model is used to generate an image of the background description text to obtain a poster background image; based on the poster background image and the display Chinese text, a preset Chinese layout model is used to perform text layout in the poster background image to obtain Chinese layout information of the display Chinese text, and the preset Chinese layout model is a neural network model obtained by training based on multiple Chinese sample posters after improving the generative adversarial network; poster generation is performed based on the Chinese layout information, the display Chinese text and the poster background image to obtain the target Chinese poster. In this embodiment, the large language model is used to directly identify the poster prompt text input by the user, and then the poster background image is generated based on the text recognition result, and more accurate Chinese layout information is generated based on the improved generative adversarial network, so that a high-quality target Chinese poster can be quickly and intelligently integrated without manual intervention, which effectively improves the generation efficiency and quality of the target Chinese poster, thereby improving the efficiency of information dissemination through the target Chinese poster image. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments of the present invention will be briefly introduced below. Obviously, the accompanying drawings in the following description are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative labor.
[0041] Figure 1is a schematic diagram of an application environment of a method for generating a target Chinese poster in an embodiment of the present invention;
[0042] Figure 2 is a flow chart of a method for generating a target Chinese poster in one embodiment of the present invention;
[0043] Figure 3 is a schematic diagram of a target Chinese poster in one embodiment of the present invention;
[0044] Figure 4 yes Figure 2 A schematic diagram of an implementation process of step S30;
[0045] Figure 5 yes Figure 2 A schematic diagram of an implementation process of step S40;
[0046] Figure 6 is a schematic diagram of a training process of a preset Chinese layout model in one embodiment of the present invention;
[0047] Figure 7 is a structural schematic diagram of a target Chinese poster generating device in one embodiment of the present invention;
[0048] Figure 8 It is a structural diagram of a computer device in one embodiment of the present invention. DETAILED DESCRIPTION
[0049] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0050] It should be understood that when used in the present specification and the appended claims, the term "comprising" indicates the presence of the described features, integrals, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components and / or their collections. It should also be understood that the term "and / or" used in the present specification and the appended claims refers to any combination of one or more of the associated listed items and all possible combinations, and includes these combinations.
[0051] In addition, in the description of the present specification and the appended claims, the terms "first", "second", "third", etc. are only used to distinguish the descriptions and cannot be understood as indicating or implying relative importance.
[0052] References to "one embodiment" or "some embodiments" etc. described in the present specification mean that one or more embodiments of the present invention include specific features, structures or characteristics described in conjunction with the embodiment. Therefore, the statements "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. that appear in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in other ways.
[0053] It should be understood that the order of execution of the steps in the following embodiments does not imply a precedence of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.
[0054] In order to illustrate the technical solution of the present invention, specific embodiments are provided below for illustration.
[0055] The target Chinese poster generation method provided by the embodiment of the present invention can be applied in Figure 1 In the application environment, the terminal device communicates with the server through the network. When it is necessary to generate a target Chinese poster, the user inputs the poster prompt text through the terminal device, and the server receives the poster prompt text input by the user and executes the poster automatic generation task.
[0056] First, the server uses a large language model to identify and classify the poster prompt text input by the user, obtains the background description text and the displayed Chinese text, and uses the text-to-image model to generate an image of the background description text to obtain the poster background image. Then, based on the poster background image and the displayed Chinese text, the server uses a preset Chinese layout model to perform text layout in the poster background image to obtain the Chinese layout information of the displayed Chinese text. Among them, the preset Chinese layout model is a neural network model obtained by training multiple Chinese sample posters after improving the generative adversarial network. Finally, the server generates a poster based on the Chinese layout information, the displayed Chinese text and the poster background image to obtain the target Chinese poster.
[0057] In this embodiment, a large language model is used to directly recognize the poster prompt text input by the user, and then a poster background image is generated based on the text recognition result, and more accurate Chinese layout information is generated based on the improved generative adversarial network, so that a high-quality target Chinese poster can be quickly and intelligently integrated without human intervention, thereby effectively improving the generation efficiency and quality of the target Chinese poster, and thus improving the efficiency of information dissemination through the target Chinese poster image.
[0058] The terminal device may be, but is not limited to, various personal computers, laptops, smart phones, tablet computers, and portable wearable devices. The server may be implemented as an independent server or a server cluster consisting of multiple servers.
[0059] In one embodiment, if Figure 2 As shown, a method for generating a target Chinese poster is provided, and the method is applied in Figure 1 The server in the example is used as an example to illustrate the process, including the following steps:
[0060] S10: Use a large language model to recognize and classify the poster prompt text input by the user to obtain background description text and display Chinese text.
[0061] When the user needs to generate a target Chinese poster, he inputs the poster prompt text through the terminal device, and the server receives the poster prompt text input by the terminal device, and then completes the target Chinese poster automatic generation task according to the poster prompt text.
[0062] In this embodiment, when a user uses an Internet editing platform through a terminal device, the user can input a poster prompt text through a poster design interface provided by the Internet editing platform. The input method of the poster prompt text can be voice input or text input.
[0063] After receiving the poster prompt text input by the terminal device, the server will first call the large language model pre-stored in the database, and use the large language model to identify and classify the poster prompt text input by the user to obtain the background description text and display Chinese text in the poster prompt text. Among them, the background description text is the description information of the background image in the target Chinese poster that the user wants to generate, and the display Chinese text is the Chinese text that appears in the target Chinese poster that the user wants to generate.
[0064] For example, the poster prompt text is input into the large language model LLM, and the large language model LLM is used to perform language recognition and classification on the poster prompt text to obtain the background description text and the display Chinese text in the poster prompt text. The process of obtaining the background description text and the display Chinese text is expressed by the following expression:
[0065] ;
[0066] Where y represents the poster prompt text input by the user; LLM represents the large language model; s represents the background description text in the poster prompt text; Indicates the displayed Chinese text in the poster prompt text, where It is a Chinese text set consisting of at least one Chinese text line, each of which will appear in the generated target Chinese poster in the form of text or graphics. That is:
[0067] ;
[0068] , ;
[0069] in, Indicates the displayed Chinese text in the poster prompt text; Indicates displaying the mth Chinese text line in the Chinese text, where m can be greater than or equal to 2; Indicates Chinese text lines, ; Indicates The nth Chinese character in a Chinese text line, that is, each Chinese text line consists of n Chinese characters (Hanzi).
[0070] Among them, the Large Language Model (LLM) is a language understanding and generation model built based on deep learning technology. It can generate coherent text with semantic and grammatical correctness through training with large-scale text data. The large language model in this embodiment can be a model of the GPT (Generative Pre-Trained Transformer) series or a model of the PaLM (Pathway Language Model) series. The large language model is used to identify and classify the poster prompt text input by the user, and the background description text and the displayed Chinese text in the poster prompt text can be accurately identified.
[0071] S20: Using a text-to-image model to generate an image from the background description text to obtain a poster background image.
[0072] After obtaining the background description text and the display Chinese text, the server will call the text-to-image model pre-stored in the database, use the text-to-image model to generate an image of the background description text, and obtain the poster background image.
[0073] Among them, the text-to-image model is a powerful text-to-image generation model. The text-to-image model can be a stable diffusion series, DALL·E series, or midjourney model that can highly fit the background image data distribution. Using the text-to-image model to generate an image from the background description text can accurately and quickly obtain the poster background image.
[0074] S30: Based on the poster background image and the displayed Chinese text, a preset Chinese layout model is used to perform text layout in the poster background image to obtain Chinese layout information of the displayed Chinese text.
[0075] After obtaining the poster background image, the server performs text layout in the poster background image using a preset Chinese layout model based on the poster background image and the displayed Chinese text, and obtains Chinese layout information of the displayed Chinese text.
[0076] Among them, the displayed Chinese text includes at least one Chinese text line, and the Chinese layout information of the displayed Chinese text includes the layout information of all Chinese text lines, and the layout information of each Chinese text line includes the geometric position of the Chinese text line in the poster background image (i.e., the center coordinates of the Chinese text line in the poster background image). In other embodiments, the layout information of each Chinese text line includes the geometric position of the Chinese text line in the poster background image, and the size information of the Chinese text line, and the size information includes the height and width of the Chinese text line. Different size information will result in different visual effects of the target Chinese poster and different information highlights, resulting in different information dissemination efficiency.
[0077] For example, the target Chinese poster that the user wants to generate can be as follows Figure 3 As shown, Figure 3 The Chinese text displayed in the text box includes two lines of Chinese text. The first line of Chinese text is: Baby / Children's Spliced Bed; the second line of Chinese text is: Free Heightening and Private Customization. Figure 3 As shown in the figure, the layout positions (geometric positions) and size information of the two Chinese text lines are different. The second Chinese text line is larger in size, with a more prominent visual effect and highlighted information. In order to ensure the effect of the target Chinese poster output later, the Chinese layout information of the displayed Chinese text includes the geometric position and size information of each Chinese text line. The quality of the target Chinese poster generated later is better, and the displayed information is more accurate, thereby improving the efficiency of information dissemination.
[0078] The preset Chinese layout model is a neural network model obtained by improving the generative adversarial network and training based on multiple Chinese sample posters. That is, the preset Chinese layout model can be an optimized generative adversarial network obtained by improving the generative adversarial network DSGAN, and then performing deep learning on the optimized generative adversarial network based on multiple Chinese sample posters to obtain a layout model.
[0079] Among them, the generative adversarial network includes an image coding layer, a fusion layer, an image generation layer and a text recognition layer. In this embodiment, the coding layer of the generative adversarial network can be optimized. For example, a text attribute coding layer can be added on the basis of image coding, wherein the text attribute is information in the Chinese text that affects the layout effect of the Chinese text, such as text size information. By adding a text attribute coding layer to the generative adversarial network, the diversity and accuracy of the subsequent fusion layer fusion can be improved, thereby increasing the Chinese text layout effect of the Chinese layout image of the image generation layer, and more accurate Chinese layout information can be obtained.
[0080] S40: Generate a poster based on the Chinese layout information, the displayed Chinese text and the poster background image to obtain a target Chinese poster.
[0081] After obtaining the Chinese layout information, the displayed Chinese text and the poster background image, the server generates a poster based on the Chinese layout information, the displayed Chinese text and the poster background image to obtain a target Chinese poster.
[0082] For example, the server may determine whether the poster prompt text input by the user includes style information of the displayed Chinese text, and the style information may include a type of information of style information such as color, font, font size, texture, etc. If the poster prompt text includes style information of the displayed Chinese text, the displayed Chinese text is stylized based on the style information to obtain stylized displayed Chinese text, and the stylized displayed Chinese text is converted into a graphic output to obtain a displayed Chinese graphic of the displayed Chinese text; then the server will directly paste the displayed Chinese graphic to the corresponding position in the poster background image based on the Chinese layout information of the displayed Chinese text to perform image fusion, so as to obtain the target Chinese poster through fusion.
[0083] In other embodiments, after obtaining the stylized displayed Chinese text, the server may also set a text box at a corresponding position in the poster background image based on the Chinese layout information, fill the stylized displayed Chinese text into the corresponding text box, and finally solidify the displayed Chinese text in the poster background image, thereby fusing and obtaining the target Chinese poster.
[0084] In this embodiment, a large language model is used to identify and classify the poster prompt text input by the user to obtain background description text and display Chinese text, and a text-to-image model is used to generate an image of the background description text to obtain a poster background image; based on the poster background image and the display Chinese text, a preset Chinese layout model is used to perform text layout in the poster background image to obtain Chinese layout information of the display Chinese text, and the preset Chinese layout model is a neural network model obtained by training multiple Chinese sample posters after improving the generative adversarial network; poster generation is performed based on the Chinese layout information, the display Chinese text and the poster background image to obtain a target Chinese poster. The large language model is used to directly identify the poster prompt text input by the user, and then a poster background image is generated based on the text recognition result, and more accurate Chinese layout information is generated based on the improved generative adversarial network, so that a high-quality target Chinese poster can be quickly and intelligently integrated without manual intervention, which effectively improves the generation efficiency and quality of the target Chinese poster, and thus improves the efficiency of information dissemination through the target Chinese poster image.
[0085] In one embodiment, if Figure 4As shown, in step S30, based on the poster background image and the displayed Chinese text, a preset Chinese layout model is used to perform text layout in the poster background image to obtain Chinese layout information of the displayed Chinese text, which specifically includes the following steps:
[0086] S31: extracting attribute information of the displayed Chinese text to obtain text attribute information of the displayed Chinese text.
[0087] After obtaining the displayed Chinese text, it is necessary to first extract attribute information of the displayed Chinese text to obtain text attribute information of the displayed Chinese text. The text attribute information refers to information in the displayed Chinese text that affects the layout effect of the Chinese text. For example, the text attribute information can be size information. The size (such as length and width) of the text is different, which affects its layout position and effect in the poster background image.
[0088] For example, the displayed Chinese text includes multiple Chinese text lines, and attribute information extraction is performed on the displayed Chinese text, which can be to extract information such as the length and width of each Chinese text line, and the size information of each Chinese text line (the size information includes the length and width of the Chinese text line, and the aspect ratio), to obtain text attribute information of the displayed Chinese text, that is, the text attribute information of the displayed Chinese text includes the size information of multiple Chinese text lines.
[0089] S32: Based on the poster background image and text attribute information, a preset Chinese layout model is used to predict the layout position of the displayed Chinese text on the poster background image to obtain Chinese layout information.
[0090] Then, based on the poster background image and the text attribute information of the displayed Chinese text, a preset Chinese layout model is used to predict the layout position of the displayed Chinese text in the poster background image to obtain Chinese layout information.
[0091] Among them, the poster background image and the text attribute information of the displayed Chinese text can be directly input into the preset Chinese layout model, and the poster background image and the text attribute information are respectively encoded by the preset Chinese layout model to obtain the encoding vector of the poster background image and the encoding vector of the text attribute information, and then the two encoding vectors are fused to predict the layout position of the displayed Chinese text in the poster background image, and obtain the Chinese layout information of the displayed Chinese text. The Chinese layout information includes the layout information of multiple Chinese text lines in the displayed Chinese text.
[0092] In this embodiment, attribute information of the displayed Chinese text is extracted to obtain text attribute information of the displayed Chinese text, and then based on the poster background image and text attribute information, a preset Chinese layout model is used to predict the layout position of the displayed Chinese text in the poster background image to obtain Chinese layout information, and the process of using the preset Chinese layout model to perform text layout in the poster background image is refined. First, attribute information of the displayed Chinese text is extracted, and then the extracted text attribute information and the poster background image are used as model inputs, and the layout position is predicted by the pre-trained preset Chinese layout model, so that the Chinese layout information fully considers the information of the poster background image and the Chinese text line, ensuring the overall aesthetics and harmony of the final target Chinese poster, with better layout effect and fast feedback speed.
[0093] In one embodiment, the text attribute information includes the number of text lines and the size ratio of the text lines of the displayed Chinese text. In step S31, the attribute information of the displayed Chinese text is extracted to obtain the text attribute information of the displayed Chinese text, which specifically includes the following steps:
[0094] S311: Determine the number of Chinese text lines contained in the displayed Chinese text, and obtain the number of text lines of the displayed Chinese text.
[0095] In this embodiment, the displayed Chinese text includes multiple Chinese text lines. When extracting attribute information from the displayed Chinese text, it is necessary to first determine the number of Chinese text lines included in the displayed Chinese text, and obtain the number of text lines of the displayed Chinese text, that is, the number of multiple Chinese text lines of the displayed Chinese text. For example, if the displayed Chinese text includes 6 Chinese text lines, the number of text lines of the displayed Chinese text is 6.
[0096] S312: Determine the length-width ratio of the Chinese text line according to the character conditions of the Chinese text line, and obtain the text line size ratio of the Chinese text line.
[0097] It is important to understand that the number of characters in a text line is different, the length of the text line is different, the fonts and sizes of the characters are different, and the width of the text line is different. Therefore, in order to ensure the accuracy of the text attribute information, it is more accurate to use the length-to-width ratio of the text line as the model input.
[0098] In summary, when extracting attribute information of displayed Chinese text, it is necessary to determine the aspect ratio of the Chinese text line according to the character situation of the Chinese text line (such as the number of characters in the text line), that is, determine the ratio of the width and length of the Chinese text line, so as to obtain the text line size ratio of each Chinese text line, and finally obtain text attribute information including the number of text lines and the text line size ratio of the displayed Chinese text. That is, the text attribute information includes the text line size ratio of each Chinese text line in the displayed Chinese text, and the number of text lines in the displayed Chinese text.
[0099] In this embodiment, the number of text lines of the displayed Chinese text is determined, and the length-width ratio of the Chinese text line is determined according to the character situation of the Chinese text line, and the text line size ratio of the Chinese text line is obtained, and the text attribute information includes. The specific acquisition process of the text attribute information of the displayed Chinese text is clarified, and the number of text lines and the text line size ratio of the displayed Chinese text are used as text attribute information, which improves the accuracy of the text attribute information, thereby improving the effect of the subsequent preset Chinese model layout prediction, and improving the accuracy of the Chinese layout information.
[0100] In one embodiment, the preset Chinese layout model includes a text attribute coding layer, an image coding layer, a fusion layer, a generation layer and a recognition layer. In step S32, based on the poster background image and the text attribute information, the preset Chinese layout model is used to predict the layout position of the displayed Chinese text on the poster background image to obtain the Chinese layout information, which specifically includes the following steps:
[0101] S321: Encode the text attribute information through the text attribute encoding layer to obtain an attribute encoding vector for displaying the Chinese text, and encode the poster background image through the image encoding layer to obtain an image encoding vector for the poster background image.
[0102] In this embodiment, the preset Chinese layout model includes a text attribute coding layer, an image coding layer, a fusion layer, a generation layer and a recognition layer. Among them, the text attribute coding layer is a network layer obtained by adding a text attribute coding layer to a traditional generative adversarial network and training based on multiple Chinese sample posters.
[0103] After obtaining the text attribute information of the displayed Chinese text, the text attribute information of the displayed Chinese text and the poster background image are input into the preset Chinese layout model, and then the text attribute information is encoded through the text attribute encoding layer to obtain the attribute encoding vector of the displayed Chinese text, and the poster background image is encoded through the image encoding layer to obtain the image encoding vector of the poster background image.
[0104] The image coding layer is a feature extraction network based on a 50-layer deep residual network (ResNet50). The input of the image coding layer is a poster background image, and its output is a 256-dimensional vector, that is, the image coding vector of the poster background image. Correspondingly, the attribute coding vector showing the Chinese text is also a 256-dimensional vector.
[0105] S322: The attribute coding vector and the image coding vector are fused through a fusion layer to obtain a target fusion vector, and text layout prediction and image generation are performed on the target fusion vector through a generation layer to obtain a Chinese layout image.
[0106] Then, the attribute coding vector output by the text attribute coding layer and the image coding vector output by the image coding layer are input into the fusion layer, and the attribute coding vector and the image coding vector are fused through the fusion layer to obtain the target fusion vector. Then, the target fusion vector output by the fusion layer is input into the generation layer, and the target fusion vector is used for text layout prediction and image generation through the generation layer to obtain the Chinese layout image.
[0107] Among them, the fusion layer is a two-layer fully connected network using the ReLU activation function, and the fusion layer includes a fusion module and a ReLU module. After the attribute coding vector and the image coding vector are input into the fusion layer, the attribute coding vector and the image coding vector are directly concatenated or fused based on the attention mechanism through the fusion module to obtain the initial fusion vector, and the initial fusion vector is input into the ReLU module, and the initial fusion vector is activated based on the ReLU activation function through the ReLU module to obtain a 256-dimensional target fusion vector.
[0108] In one embodiment, the displayed Chinese text includes a plurality of Chinese text lines, and the attribute coding vector of the displayed Chinese text includes a text line number vector of the displayed Chinese text and a size ratio vector of each Chinese text line. After the attribute coding vector and the image coding vector are input into the fusion layer, the text line number vector and the size ratio vector of each Chinese text line are directly spliced through the fusion module to obtain an initial fusion vector, and the initial fusion vector is input into the ReLU module, and the initial fusion vector is activated based on the ReLU activation function through the ReLU module to obtain a 256-dimensional target fusion vector. In this embodiment, the attribute coding vector can express more layout-related information, so that a more accurate target fusion vector can be spliced and fused, which is conducive to subsequent prediction of more accurate Chinese layout information.
[0109] S323: Perform text position recognition on the Chinese layout image through the recognition layer to obtain Chinese layout information showing Chinese text.
[0110] Then, the Chinese layout image output by the generation layer is input into the recognition layer, and the recognition layer performs text position recognition on the Chinese layout image, that is, recognizes the geometric position and size information (including length and width) of each Chinese text line in the Chinese layout image, and obtains the layout information of each Chinese text line, that is, the Chinese layout information of the Chinese text is displayed.
[0111] In this embodiment, the text attribute information is encoded by the text attribute encoding layer to obtain an attribute encoding vector for displaying Chinese text, and the poster background image is encoded by the image encoding layer to obtain an image encoding vector for the poster background image; the attribute encoding vector and the image encoding vector are fused by the fusion layer to obtain a target fusion vector, and the target fusion vector is predicted for text layout and generated for image by the generation layer to obtain a Chinese layout image; the Chinese layout image is recognized for text position by the recognition layer to obtain Chinese layout information for displaying Chinese text. The specific structure of the preset Chinese layout model is clarified, and the specific process of obtaining Chinese layout information is clarified. By adding a text attribute encoding layer to the traditional generative adversarial network, the diversity and accuracy of the subsequent fusion layer fusion can be improved, thereby increasing the Chinese text layout effect predicted by the image generation layer, and obtaining more accurate Chinese layout information.
[0112] In other embodiments, the preset Chinese layout model may further include a text attribute coding layer, a text semantic coding layer, an image coding layer, a fusion layer, a generation layer, and a recognition layer. The process of obtaining Chinese layout information may further include: inputting the displayed Chinese text, text attribute information, and poster background image into the preset Chinese layout model, semantically encoding the displayed Chinese text through the text semantic coding layer to obtain a semantic coding vector; encoding the text attribute information through the text attribute coding layer to obtain an attribute coding vector of the displayed Chinese text, and encoding the poster background image through the image coding layer to obtain an image coding vector of the poster background image; fusing the semantic coding vector, the attribute coding vector, and the image coding vector through the fusion layer to obtain a target fusion vector, and performing text layout prediction and image generation on the target fusion vector through the generation layer to obtain a Chinese layout image; performing text position recognition on the Chinese layout image through the recognition layer to obtain Chinese layout information of the displayed Chinese text. The diversity and accuracy of the subsequent fusion layer fusion can be improved, thereby increasing the Chinese text layout effect predicted by the image generation layer, and obtaining more accurate Chinese layout information.
[0113] In one embodiment, the text attribute information includes the number of text lines and the size ratio of the text lines for displaying Chinese text, and the attribute encoding vector includes the number of text lines vector and the size ratio vector. In step S321, the text attribute information is encoded by the text encoding layer to obtain the attribute encoding vector for displaying Chinese text, which specifically includes the following steps:
[0114] S3211: Encode the number of text lines through the number encoder of the text encoding layer to obtain a text line number vector.
[0115] In this embodiment, the text attribute information includes the number of text lines and the text line size ratio of the Chinese text, and the attribute encoding vector includes the text line number vector and the size ratio vector of each Chinese text line. Among them, the text encoding layer includes a quantity encoder and a ratio encoder. Among them, the quantity encoder is a two-layer fully connected neural network, which outputs a 256-dimensional text line quantity vector; the ratio encoder is also a two-layer fully connected neural network, and its output is a 256-dimensional size ratio vector.
[0116] After obtaining the text attribute information of the displayed Chinese text, the text attribute information of the displayed Chinese text is input into a preset Chinese layout model, and the number of text lines is quantitatively encoded by a quantity encoder of the text encoding layer to obtain a text line quantity vector.
[0117] S3212: Proportionally encode the text line size ratio through a proportional encoder of the text encoding layer to obtain a size ratio vector.
[0118] At the same time, the text line size ratio of each Chinese text line is proportionally encoded through the proportional encoder of the text encoding layer to obtain the size ratio vector of each Chinese text line, thereby obtaining an attribute encoding vector including the text line quantity vector and the size ratio vector of each Chinese text line.
[0119] In this embodiment, the text encoding layer includes a proportional encoder and a number encoder. The trainable number encoder (Number Encoder, NE) and proportional encoder (Rate Encoder, RE) are added based on the traditional adversarial generative network, which can improve the accuracy of the preset Chinese layout model; when predicting Chinese layout information through the preset Chinese layout model, in addition to considering the poster background image, the number of text lines and the aspect ratio of the displayed Chinese text are also considered, so that the Chinese text layout is completely matched with the displayed Chinese text in terms of the number of elements and text size, thereby improving the layout effect of the Chinese text.
[0120] In this embodiment, the number of text lines is quantitatively encoded by the quantity encoder of the text encoding layer to obtain a text line quantity vector, and the text line size ratio is proportionally encoded by the ratio encoder of the text encoding layer to obtain a size ratio vector, which clarifies the acquisition process of the attribute coding vector and improves the accuracy of the attribute coding vector.
[0121] In other embodiments, the text attribute information includes the number of text lines displaying Chinese text, the length and width of each Chinese text line, and the attribute coding vector includes the text line number vector and the length and width coding vector. In step S321, the text attribute information is encoded through the text coding layer to obtain the attribute coding vector displaying Chinese text, including: the number of text lines is encoded through the number encoder of the text coding layer to obtain the text line number vector, the length and width of each Chinese text line is encoded through the size encoder of the text coding layer to obtain the length and width coding vector of each Chinese text line, and then the attribute coding vector including the text line number vector and the length and width coding vector of each Chinese text line is obtained.
[0122] In one embodiment, the quantity encoder includes a one-hot encoding module and a quantity encoding module. In step S3211, the quantity encoder of the text encoding layer performs quantity encoding on the quantity of text lines to obtain a text line quantity vector, which specifically includes the following steps:
[0123] S3011: Perform one-hot encoding on the number of text lines through the one-hot encoding module of the number encoder to obtain a one-hot encoding vector of the number of text lines.
[0124] S3012: Encode the one-hot encoding vector of the number of text lines through the number encoding module of the number encoder to obtain a text line number vector.
[0125] In this embodiment, the quantity encoder includes a one-hot encoding module and a quantity encoding module. The one-hot encoding module is a module that uses a one-hot encoding algorithm to map the input to a high-dimensional space for vector conversion, and the output of the one-hot encoding module is a 32-dimensional vector. The one-hot encoding algorithm is a method for converting discrete variables into multidimensional vectors. One-hot encoding is suitable for most algorithms, avoids interference caused by the size relationship between features, and can handle categorical variables well. The quantity encoding module is a two-layer fully connected neural network, whose input is a 32-dimensional vector and outputs a 256-dimensional text line quantity vector; the ratio encoder is also a two-layer fully connected neural network, whose output is a 256-dimensional size ratio vector.
[0126] After obtaining the text attribute information of the displayed Chinese text, the number of text lines of the displayed Chinese text is input into the quantity encoder, and the number of text lines is one-hot encoded through the one-hot encoding module to obtain the one-hot encoded vector of the number of text lines. Then, the one-hot encoded vector of the number of text lines output by the one-hot encoding module is input into the quantity encoding module, and the one-hot encoded vector of the number of text lines is encoded through the quantity encoding module to obtain the text line number vector.
[0127] In this embodiment, the number of text lines displaying Chinese text is first one-hot encoded, and then the one-hot encoded vector is encoded to obtain a text line number vector, which can eliminate the interference caused by the size relationship between adjacent features and improve the accuracy of the text line number vector obtained by subsequent encoding.
[0128] In one embodiment, the proportional encoder includes a one-hot encoding module and a proportional encoding module. In step S3212, the proportional encoder of the text encoding layer performs proportional encoding on the text line size ratio to obtain a size ratio vector, which specifically includes the following steps:
[0129] S3021: One-hot encoding the text line size ratio through a one-hot encoding module of a proportional encoder to obtain a one-hot vector of the text line size ratio;
[0130] S3022: Encode the one-hot vector of the text line size ratio through the proportional encoding module of the proportional encoder to obtain a size ratio vector.
[0131] In this embodiment, the proportional encoder includes a one-hot encoding module and a quantity encoding module. The one-hot encoding module is a module that uses a one-hot encoding algorithm to map the input to a high-dimensional space for vector conversion, and the output of the one-hot encoding module is a 32-dimensional vector. The quantity encoding module is a two-layer fully connected neural network, whose input is a 32-dimensional vector and outputs a 256-dimensional text line quantity vector; the proportional encoder is also a two-layer fully connected neural network, whose output is a 256-dimensional size ratio vector.
[0132] After obtaining the text attribute information of the displayed Chinese text, the text line size ratio of each Chinese text line in the displayed Chinese text is respectively input into the proportional encoder, and each text line size ratio is one-hot encoded through the one-hot encoding module to obtain the one-hot encoded vector of each text line size ratio, and then the one-hot encoded vector output by the one-hot encoding module is input into the proportional encoding module, and the one-hot encoded vector of each text line size ratio is encoded through the proportional encoding module to obtain the size ratio vector of each Chinese text line.
[0133] In this embodiment, the text line size ratio of each Chinese text line in the displayed Chinese text is first one-hot encoded, and then the one-hot encoded vector of each text line size ratio is encoded to obtain the size ratio vector of each Chinese text line. This can eliminate the interference caused by the size relationship between adjacent features and improve the accuracy of the size ratio vector obtained by subsequent encoding.
[0134] In one embodiment, the text encoding layer includes a one-hot encoder, a quantity encoder and a ratio encoder, and the one-hot encoder is connected to the quantity encoder and the ratio encoder respectively. Wherein, the quantity encoder and the ratio encoder are both two-layer fully connected neural networks, the input of both is a 32-dimensional vector, and the output of both is a 256-dimensional vector. In the process of encoding the text attribute information through the text encoding layer, the number of text lines and the text line size ratio of each Chinese text line are firstly one-hot encoded by the one-hot encoder to obtain the one-hot vector of the number of text lines and the one-hot vector of the size ratio of each text line; then, the one-hot vector of the number of text lines is quantitatively encoded by the quantity encoder to obtain the text line quantity vector, and the one-hot vector of the size ratio of each text line is encoded by the ratio encoder to obtain the size ratio vector of each Chinese text line, and then the attribute encoding vector including the text line number vector and the size ratio vector of each Chinese text line is obtained. The structure of the preset Chinese layout model is simplified and the server load is reduced.
[0135] In one embodiment, if Figure 5 As shown, in step S40, based on the poster background image and the displayed Chinese text, a preset Chinese layout model is used to perform text layout in the poster background image to obtain Chinese layout information of the displayed Chinese text, which specifically includes the following steps:
[0136] S41: Perform style transfer and graphic conversion on the displayed Chinese text based on the poster background image to generate a target Chinese graphic for the displayed Chinese text.
[0137] For example, a graphic Chinese generation model can be obtained, and the preset style transfer model can be a traditional style transfer model, such as a style transfer model based on a convolutional neural network or a style transfer model based on a variational autoencoder; the poster background image and the displayed Chinese text are directly input into the preset style transfer model, and the style of the poster background image is transferred to the displayed Chinese text through the preset style transfer model to obtain stylized displayed Chinese text; then, the stylized displayed Chinese text is converted into a graphic through a graphic converter to obtain the graphic font of each Chinese text line in the displayed Chinese text, that is, the target Chinese graphic, which is simple and convenient.
[0138] S42: Based on the Chinese layout information, the target Chinese graphic and the poster background image are fused to obtain a target Chinese poster.
[0139] After obtaining the target Chinese graphic for displaying Chinese text, the target Chinese graphic and the poster background image are fused based on the Chinese layout information to obtain the target Chinese poster. The Chinese layout information includes the layout information of each Chinese text line in the displayed Chinese text. Based on the layout information of each Chinese text line, the graphic corresponding to the Chinese text line is pasted to the poster background image by geometric pasting and solidified, so as to obtain the target Chinese poster.
[0140] In this embodiment, the style of the displayed Chinese text is transferred and converted into a graphic based on the poster background image to generate a target Chinese graphic for displaying the Chinese text. Based on the Chinese layout information, the target Chinese graphic and the poster background image are fused to obtain a target Chinese poster. The style of the poster background image is transferred to the displayed Chinese text, so that the background and Chinese characters in the poster are unified and echo each other, which can increase the harmony between the background and Chinese characters in the target Chinese poster, thereby increasing the visual effect of the target Chinese poster; at the same time, the stylized displayed Chinese text is converted into a graphic and then fused, which can ensure the accuracy of the output Chinese graphic and avoid missing Chinese strokes. In addition, style transfer through the style transfer model is simple, convenient and accurate.
[0141] In one embodiment, step S41, that is, performing style migration and graphic conversion on the displayed Chinese text based on the poster background image to generate a target Chinese graphic for displaying the Chinese text, specifically includes the following steps:
[0142] S411: Based on the Chinese layout information of the displayed Chinese text, the poster background image is segmented into regions to obtain a background region image of the region where the displayed Chinese text is located.
[0143] The Chinese layout information for displaying Chinese text includes the layout information of each Chinese text line in the displayed Chinese text, and the layout information of each Chinese text line includes the geometric position of the Chinese text line in the poster background image, and the size information of the Chinese text line, and the size information includes the height and width of the Chinese text line. Different size information will result in different visual effects and information highlights of the target Chinese poster, resulting in different information dissemination efficiency.
[0144] The server can determine the area where each Chinese text line is located in the poster background image based on the geometric position of each Chinese text line in the poster background image and the size information of the Chinese text line, thereby segmenting the area to obtain the regional image of each Chinese text line and obtain the background area image showing the area where the Chinese text is located.
[0145] S412: Using the pre-trained graphic Chinese generation model, style migration and graphic conversion are performed on the displayed Chinese text based on the background area image to obtain a target Chinese graphic for displaying the Chinese text.
[0146] Among them, first obtain a pre-trained graphic Chinese generation model, which is a neural network model trained on a preset network framework based on multiple Chinese sample posters. Then, the displayed Chinese text and the local image of the area where the displayed Chinese text is located are input into the graphic Chinese generation model, and the style of the background area image is transferred to the displayed Chinese text through the graphic Chinese generation model, and then converted into a graphic to obtain a target Chinese graphic for the displayed Chinese text. The target Chinese graphic includes the graphic font of each Chinese character in each Chinese text line.
[0147] In this embodiment, based on the Chinese layout information of the displayed Chinese text, the local image corresponding to the displayed Chinese text in the poster background image is determined, and then the pre-trained graphic Chinese generation model is used to transfer the style of the local image to the displayed Chinese text and graph it, so that the style of the displayed Chinese text is consistent with the background of the area where it is located, further increasing the consistency of the graphic and text styles, and further enhancing the visual effect of the subsequent target Chinese poster.
[0148] In one embodiment, the graphic Chinese generation model (or preset network framework) includes an encoding network, a style extraction network, a style transfer network and a graphic conversion network. In step S412, the graphic Chinese generation model obtained by pre-training is used to perform style transfer and graphic conversion based on the background area image on the displayed Chinese text to obtain a target Chinese graphic for displaying Chinese text, including:
[0149] S4121: Encode the displayed Chinese text and the background area image respectively through the encoding network to obtain the Chinese encoding vector of the displayed Chinese text and the area background vector.
[0150] Among them, the displayed Chinese text includes at least one Chinese text line, and the Chinese encoding vector includes the text features and stroke features of each Chinese character in each Chinese text line; the displayed Chinese text and the background area image (and the poster background image) are input into the encoding network, and the encoding network is used to achieve: text encoding and stroke encoding of each Chinese character in the displayed Chinese text to obtain the text vector and stroke vector of each Chinese character; image encoding is performed on the background area image (and the poster background image) to obtain the regional background vector (and the overall background vector).
[0151] S4122: extracting style information from the Chinese code vector and the regional background vector through a style generation network to obtain a style vector, which at least includes a font vector and a color vector.
[0152] Among them, the Chinese coding vector and the regional background vector (and the overall background vector) are input into the style generation network, and the style generation network is used to achieve: splicing the text features of each Chinese character in each Chinese text line and the regional background vector (and the overall background vector) to obtain a first splicing feature; based on the first splicing feature, the color information and font information of the Chinese promotional text are extracted to obtain the color vector and font vector of each Chinese text line.
[0153] S4123: Migrate the font vector to the Chinese encoding vector through the migration network and generate stylized Chinese text for display.
[0154] Among them, the font vector, text feature and / or stroke feature of each Chinese text line is input into the migration network, and the migration network is used to achieve: splicing the font vector, text feature and / or stroke feature of each Chinese text line to obtain a second splicing feature; and generating a stylized font based on the second splicing feature to obtain a stylized displayed Chinese text.
[0155] S4124: Update the color vector to the stylized displayed Chinese text through the graphic conversion network, and generate a target Chinese graphic for displaying the Chinese text.
[0156] The color vector of each Chinese text line and the stylized displayed Chinese text are input into a graphic conversion network, the text color of the stylized displayed Chinese text is updated to the color corresponding to the color vector, the target Chinese text is obtained, and the target Chinese text is converted into a graphic format to obtain a target Chinese graphic for displaying the Chinese text. The target Chinese graphic for displaying the Chinese text includes graphic fonts of all Chinese characters.
[0157] In this embodiment, the specific structure of the graphic Chinese generation model is clarified. The display Chinese text and the background area image are encoded respectively through the encoding network to obtain the Chinese encoding vector and the regional background vector of the display Chinese text; the style information of the Chinese encoding vector and the regional background vector is extracted through the style generation network to obtain the style vector, which at least includes the font vector and the color vector. The font vector is then transferred to the Chinese encoding vector through the migration network, and the stylized display Chinese text is generated. Finally, the color vector is updated to the stylized display Chinese text through the graphic conversion network to generate the target Chinese graphic of the display Chinese text. The graphic Chinese generation model can generate stylized Chinese graphic fonts with different fonts and colors, ensuring the accuracy and style diversity of the generated Chinese characters, thereby improving the visual effect of the target Chinese graphic, and then improving the quality of the subsequent generation of the target Chinese poster.
[0158] In one embodiment, before step S30, it is necessary to first train a preset Chinese layout model, and then use the preset Chinese layout model to perform text layout in the poster background image. Figure 6 As shown, the preset Chinese layout model is trained in the following way:
[0159] S01: Acquire multiple Chinese sample posters, and pre-process the multiple Chinese sample posters respectively to obtain a background sample image of each Chinese sample poster, standard attribute information of Chinese sample text, and a standard layout position of the Chinese sample text in the background sample image.
[0160] The standard attribute information of the Chinese sample text includes the size ratio of each Chinese text line in the Chinese sample text (ie, the ratio of width to length). In other embodiments, the standard attribute information also includes the number of Chinese text lines, ie, the number of text lines.
[0161] For example, a sample poster in Chinese such as Figure 3 As shown, the Chinese sample poster is preprocessed to obtain the background sample image, Chinese sample text, and standard layout position of the Chinese sample text in the background sample image of the Chinese sample poster. Among them, the Chinese sample text of the Chinese sample poster includes 2 Chinese text lines, the first Chinese text line is: baby / child splicing bed, and the second Chinese text line is: free heightening and private customization. The background sample image of the Chinese sample poster is the Chinese sample poster after the Chinese sample text is removed; the standard layout position of the Chinese sample text in the background sample image is the position of the Chinese sample text in the image. The standard attribute information of the Chinese sample text includes the number of text lines 2 and the size ratio of the two Chinese text lines.
[0162] S02: Input the background sample image of the Chinese sample poster and the standard attribute information of the Chinese sample text into the pre-trained network to perform text layout prediction, and obtain the predicted layout position of the Chinese sample text in the background sample image.
[0163] Then, a pre-trained network is obtained, which is a neural network obtained by adding a text attribute encoding layer to the generative adversarial network. The background sample image and Chinese sample text of the Chinese sample poster are input into the pre-trained network for text layout prediction, and the predicted layout position of the Chinese sample text in the background sample image is obtained.
[0164] Specifically, the generative adversarial network includes an image coding layer, a fusion layer, an image generation layer and a text recognition layer. The generative adversarial network includes a text attribute coding layer, an image coding layer, a fusion layer, an image generation layer and a text recognition layer. Among them, the text attribute coding layer includes a quantity encoder and a ratio encoder.
[0165] The background sample image of the Chinese sample poster and the standard attribute information of the Chinese sample text are input into the pre-trained network, the standard attribute information is encoded through the text attribute encoding layer to obtain a standard attribute vector, and the background sample image is encoded through the image encoding layer to obtain a standard background vector; the standard attribute vector and the standard background vector are fused through the fusion layer to obtain a standard fusion vector, and the text layout prediction and image generation are performed on the standard fusion vector through the generation layer to obtain a predicted image; the text position recognition is performed on the predicted image through the recognition layer to obtain the predicted layout position of the Chinese sample text in the background sample image.
[0166] S03: Determine a total loss value according to the predicted layout position and the standard layout position.
[0167] After the predicted layout position is obtained, the total loss value is determined according to the predicted layout position and the standard layout position. For example, the similarity between the predicted layout position and the standard layout position is directly calculated to obtain the similarity between the two as the total loss value.
[0168] In other embodiments, the standard fusion vector output by the fusion layer in the pre-trained network can also be obtained, and the standard attribute vector of the standard attribute information and the standard background vector of the background sample image are fused by the fusion layer; then the total loss value is determined according to the standard fusion vector, the predicted layout position and the standard layout position. The total loss value is a composite loss value obtained by performing loss calculation on the standard fusion vector, the predicted layout position and the standard layout position using a composite loss function. The composite loss function is composed of an adversarial loss function, a reconstruction loss function, a negative log-likelihood loss function NLL, an absolute value loss function L1 and an intersection-over-union loss function IoU. Using the composite loss function, the total loss value obtained by performing loss calculation on the standard fusion vector, the predicted layout position and the standard layout position can improve the accuracy of the total loss value.
[0169] S04: When the total loss value does not meet the convergence condition, continue to iterate the parameters of the pre-trained network according to multiple Chinese sample posters until the total loss value meets the convergence condition, determine that the pre-trained network converges, and output the converged pre-trained network as the preset Chinese layout model.
[0170] After obtaining the total loss value, determine whether the total loss value meets the convergence conditions. When the total loss value does not meet the convergence conditions, repeat steps S01-S04, and continue to iterate the parameters of the pre-trained network based on multiple Chinese sample posters until the total loss value meets the convergence conditions. Then, determine that the pre-trained network converges, and output the converged pre-trained network as the preset Chinese layout model.
[0171] Among them, when the total loss value is less than or equal to the preset value, or when the total loss value is greater than the preset value but the number of model iterations is greater than or equal to the preset number (such as 1000 times), it is determined that the total loss value does not meet the convergence condition.
[0172] This embodiment clarifies the specific training process of the preset Chinese layout model. Based on the background sample images of multiple Chinese sample posters and the standard attribute information of their Chinese sample texts, the pre-trained network is deeply learned to obtain a preset Chinese layout model that is more in line with Chinese layout habits and has higher accuracy. This allows the preset Chinese layout model to perform Chinese text layout with better results, providing a solid foundation for the subsequent execution of automatic poster generation tasks.
[0173] In addition, the specific structure of the preset Chinese layout model is also clarified in this embodiment. By adding a text attribute encoding layer to the traditional generative adversarial network, the diversity and accuracy of the subsequent fusion layer fusion can be improved, thereby increasing the Chinese text layout effect predicted by the image generation layer, and obtaining more accurate Chinese layout information.
[0174] It should be understood that the order of execution of the steps in the above embodiment does not necessarily mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiment of the present invention.
[0175] In one embodiment, a target Chinese poster generation device is provided, and the target Chinese poster generation device corresponds to the target Chinese poster generation method in the above embodiment. Figure 7 As shown, the target Chinese poster generation device includes a text recognition module 701, an image generation module 702, a Chinese layout module 703 and a poster generation module 704. The detailed description of each functional module is as follows:
[0176] The text recognition module 701 is used to use a large language model to recognize and classify the poster prompt text input by the user to obtain the background description text and the display Chinese text;
[0177] An image generation module 702 is used to generate an image from the background description text using a text-to-image model to obtain a poster background image;
[0178] The Chinese layout module 703 is used to perform text layout in the poster background image based on the poster background image and the displayed Chinese text using a preset Chinese layout model to obtain Chinese layout information for the displayed Chinese text. The preset Chinese layout model is a neural network model obtained by training a plurality of Chinese sample posters after improving the generative adversarial network;
[0179] The poster generation module 704 is used to generate a poster based on the Chinese layout information, the displayed Chinese text and the poster background image to obtain a target Chinese poster.
[0180] Optionally, the Chinese layout module 703 is specifically used for:
[0181] Extracting attribute information of the displayed Chinese text to obtain text attribute information of the displayed Chinese text;
[0182] Based on the poster background image and text attribute information, a preset Chinese layout model is used to predict the layout position of the displayed Chinese text on the poster background image to obtain Chinese layout information.
[0183] Optionally, the Chinese layout module 703 is further used for:
[0184] Determine the number of Chinese text lines contained in the displayed Chinese text, and obtain the number of text lines of the displayed Chinese text;
[0185] According to the characters of the Chinese text line, the length and width ratio of the Chinese text line is determined to obtain the text line size ratio of the Chinese text line. The text attribute information includes the number of text lines displaying Chinese text and the text line size ratio.
[0186] Optionally, the poster generation module 704 is specifically used for:
[0187] Using the preset style transfer model, the style of the displayed Chinese text is transferred and converted based on the poster background image to generate the target Chinese graphic for displaying the Chinese text;
[0188] Based on the Chinese layout information, the target Chinese graphic and the poster background image are fused to obtain the target Chinese poster.
[0189] Optionally, the target Chinese poster generation device further includes a model training module 705, which is used to train and obtain a preset Chinese layout model in the following manner:
[0190] Acquire multiple Chinese sample posters, and pre-process the multiple Chinese sample posters respectively to obtain a background sample image, a Chinese sample text, and a standard layout position of the Chinese sample text in the background sample image of each Chinese sample poster;
[0191] The background sample image of the Chinese sample poster and the standard attribute information of the Chinese sample text are input into the pre-trained network for text layout prediction, and the predicted layout position of the Chinese sample text in the background sample image is obtained. The pre-trained network is a neural network obtained by adding a text attribute encoding layer to the generative adversarial network;
[0192] Determine the total loss value according to the predicted layout position and the standard layout position;
[0193] When the total loss value does not meet the convergence condition, continue to iterate the parameters of the pre-trained network based on multiple Chinese sample posters until the total loss value meets the convergence condition, determine that the pre-trained network converges, and output the converged pre-trained network as the preset Chinese layout model.
[0194] For the specific limitations of the target Chinese poster generation device, please refer to the limitations of the target Chinese poster generation method above, which will not be repeated here. Each module in the above-mentioned target Chinese poster generation device can be implemented in whole or in part by software, hardware and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.
[0195] In one embodiment, a computer device is provided, whose internal structure diagram can be as follows: Figure 8 As shown. The computer device includes a processor, a memory, a network interface, a display screen and an input device connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external server through a network connection. When the computer program is executed by the processor, a target Chinese poster generation method is implemented.
[0196] In one embodiment, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps of the target Chinese poster generation method described above are implemented.
[0197] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps of the above-mentioned target Chinese poster generation method are implemented.
[0198] A person skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory.
[0199] Those skilled in the art can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example. In actual applications, the above-mentioned functions can be distributed and completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above.
[0200] The embodiments described above are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be included in the protection scope of the present invention.
Claims
1. A method for generating a target Chinese poster, It is characterized in that include: A large language model is used to identify and classify the poster prompt text input by the user to obtain the background description text and the displayed Chinese text; Using a text-to-image model to generate an image from the background description text to obtain a poster background image; Based on the poster background image and the displayed Chinese text, a preset Chinese layout model is used to perform text layout in the poster background image to obtain Chinese layout information of the displayed Chinese text, wherein the preset Chinese layout model is a neural network model obtained by training a plurality of Chinese sample posters after improving a generative adversarial network; Generating a poster based on the Chinese layout information, the displayed Chinese text and the poster background image to obtain a target Chinese poster includes: Performing style migration and graphic conversion on the displayed Chinese text based on the poster background image to generate a target Chinese graphic for the displayed Chinese text; Based on the Chinese layout information, the target Chinese graphic and the poster background image are fused to obtain the target Chinese poster; The step of performing style migration and graphic conversion on the displayed Chinese text based on the poster background image to generate a target Chinese graphic for the displayed Chinese text includes: Based on the Chinese layout information of the displayed Chinese text, the poster background image is segmented into regions to obtain a background region image of the region where the displayed Chinese text is located; Using a pre-trained Chinese-in-graphics generation model, the Chinese-in-graphics generation model includes an encoding network, a style extraction network, a style transfer network, and a graphic conversion network, performing style transfer and graphic conversion based on the background area image on the displayed Chinese text to obtain a target Chinese graphic for the displayed Chinese text, including: The displayed Chinese text and the background area image are respectively encoded by the encoding network to obtain a Chinese encoding vector of the displayed Chinese text and an area background vector; Extracting style information from the Chinese code vector and the regional background vector through a style generation network to obtain a style vector, wherein the style vector includes at least a font vector and a color vector; Migrating the font vector to the Chinese encoding vector through the style migration network, and generating the stylized displayed Chinese text; The color vector is updated to the stylized displayed Chinese text through the graphic conversion network to generate a target Chinese graphic for the displayed Chinese text.
2. The target Chinese poster generation method as claimed in claim 1, It is characterized in that The method of performing text layout in the poster background image based on the poster background image and the displayed Chinese text using a preset Chinese layout model to obtain Chinese layout information of the displayed Chinese text includes: Extracting attribute information of the displayed Chinese text to obtain text attribute information of the displayed Chinese text; Based on the poster background image and the text attribute information, the preset Chinese layout model is used to predict the layout position of the displayed Chinese text in the poster background image to obtain the Chinese layout information.
3. The target Chinese poster generation method as claimed in claim 2, It is characterized in that The extracting attribute information of the displayed Chinese text to obtain text attribute information of the displayed Chinese text includes: Determine the number of Chinese text lines contained in the displayed Chinese text to obtain the number of text lines of the displayed Chinese text; According to the characters of the Chinese text line, the length-width ratio of the Chinese text line is determined to obtain the text line size ratio of the Chinese text line. The text attribute information includes the number of text lines displaying Chinese text and the text line size ratio.
4. The target Chinese poster generation method as claimed in claim 2, It is characterized in that The preset Chinese layout model includes a text attribute coding layer, an image coding layer, a fusion layer, a generation layer and a recognition layer. Based on the poster background image and the text attribute information, the preset Chinese layout model is used to predict the layout position of the displayed Chinese text in the poster background image to obtain the Chinese layout information, including: The text attribute information is encoded by the text attribute encoding layer to obtain the attribute encoding vector of the displayed Chinese text, and the poster background image is encoded by the image encoding layer to obtain the image encoding vector of the poster background image; The attribute coding vector and the image coding vector are fused by the fusion layer to obtain a target fusion vector, and the target fusion vector is subjected to text layout prediction and image generation by the generation layer to obtain a Chinese layout image; The Chinese layout image is subjected to text recognition by the recognition layer to obtain Chinese layout information of the displayed Chinese text.
5. The target Chinese poster generation method as claimed in claim 4, It is characterized in that The text attribute information includes the number of text lines and the text line size ratio of the displayed Chinese text, the attribute encoding vector includes the text line number vector and the size ratio vector, and encoding the text attribute information through the text attribute encoding layer to obtain the attribute encoding vector of the displayed Chinese text includes: The quantity encoder of the text attribute encoding layer performs quantity encoding on the quantity of the text lines to obtain a text line quantity vector; The text line size ratio is proportionally encoded by a proportional encoder of the text attribute encoding layer to obtain a size ratio vector.
6. The target Chinese poster generation method according to any one of claims 1 to 5, It is characterized in that The preset Chinese layout model is trained in the following way: Acquire a plurality of the Chinese sample posters, and pre-process the plurality of the Chinese sample posters respectively to obtain a background sample image of each of the Chinese sample posters, standard attribute information of the Chinese sample text, and a standard layout position of the Chinese sample text in the background sample image; Inputting the background sample image of the Chinese sample poster and the standard attribute information of the Chinese sample text into a pre-trained network to perform text layout prediction, and obtaining the predicted layout position of the Chinese sample text in the background sample image, wherein the pre-trained network is a neural network obtained by adding a text attribute encoding layer to the generative adversarial network; Determining a total loss value according to the predicted layout position and the standard layout position; When the total loss value does not meet the convergence condition, continue to iterate the parameters of the pre-trained network based on the multiple Chinese sample posters until the total loss value meets the convergence condition, determine that the pre-trained network converges, and output the converged pre-trained network as the preset Chinese layout model.
7. A target Chinese poster generation device, It is characterized in that include: The text recognition module is used to use a large language model to recognize and classify the poster prompt text input by the user to obtain the background description text and the display Chinese text; An image generation module, used for generating an image from the background description text using a text-to-image model to obtain a poster background image; A Chinese layout module, for performing text layout in the poster background image based on the poster background image and the displayed Chinese text using a preset Chinese layout model to obtain Chinese layout information of the displayed Chinese text, wherein the preset Chinese layout model is a neural network model obtained by training a plurality of Chinese sample posters after improving a generative adversarial network; A poster generation module, used to generate a poster based on the Chinese layout information, the displayed Chinese text and the poster background image to obtain a target Chinese poster, including: Performing style migration and graphic conversion on the displayed Chinese text based on the poster background image to generate a target Chinese graphic for the displayed Chinese text; Based on the Chinese layout information, the target Chinese graphic and the poster background image are fused to obtain the target Chinese poster; The step of performing style migration and graphic conversion on the displayed Chinese text based on the poster background image to generate a target Chinese graphic for the displayed Chinese text includes: Based on the Chinese layout information of the displayed Chinese text, the poster background image is segmented into regions to obtain a background region image of the region where the displayed Chinese text is located; Using a pre-trained Chinese-in-graphics generation model, the Chinese-in-graphics generation model includes an encoding network, a style extraction network, a style transfer network, and a graphic conversion network, performing style transfer and graphic conversion based on the background area image on the displayed Chinese text to obtain a target Chinese graphic for the displayed Chinese text, including: The displayed Chinese text and the background area image are respectively encoded by the encoding network to obtain a Chinese encoding vector of the displayed Chinese text and an area background vector; Extracting style information from the Chinese code vector and the regional background vector through a style generation network to obtain a style vector, wherein the style vector includes at least a font vector and a color vector; Migrating the font vector to the Chinese encoding vector through the style migration network, and generating the stylized displayed Chinese text; The color vector is updated to the stylized displayed Chinese text through the graphic conversion network to generate a target Chinese graphic for the displayed Chinese text.
8. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, It is characterized in that When the processor executes the computer program, the steps of the target Chinese poster generation method according to any one of claims 1 to 6 are implemented.
9. A computer-readable storage medium storing a computer program. It is characterized in that When the computer program is executed by a processor, the steps of the target Chinese poster generation method according to any one of claims 1 to 6 are implemented.
