Layout generation method and device, medium and equipment
By acquiring and processing the element attributes and task instruction information of the layout task, and using the layout prediction model to generate structured layout information, it solves the problems of low efficiency and insufficient generalization ability of automated typesetting layout generation in the existing technology, and achieves a more intelligent and efficient The layout is generated.
Patent Information
- Application Number
- CN202410700614.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-31
- Publication Date
- 2024-09-06
AI Technical Summary
Existing technologies are inefficient in automated layout generation and are difficult to flexibly respond to different design tasks. Moreover, deep learning-based methods are difficult to generalize to a variety of layout design tasks, and their ability to understand users' natural language descriptions is insufficient.
Provide a layout generation method that obtains the element attribute information and task instruction information of the layout task, performs text tokenization processing, and inputs the layout prediction model for processing. It combines the feature representation module, the content awareness module and the layout prediction module to generate a structured structure. Layout information that supports determining the layout of view elements in a preset view or background image.
It improves the intelligence and effectiveness of layout generation, can handle multiple layout types of tasks, meets the needs of automated graphic design, improves the ability to understand natural language descriptions, and achieves more flexible and efficient layout generation.
Smart Images

Figure CN118607031A
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence technology, and in particular to a layout generation method, device, medium and equipment. Background Art
[0002] Artificial Intelligence (AI) is a comprehensive technology in computer science. By studying the design principles and implementation methods of various intelligent machines, it enables machines to have the functions of perception, reasoning and decision-making. Artificial intelligence technology is an interdisciplinary subject that covers a wide range of fields, such as natural language processing, machine learning, deep learning and other major directions. With the development of technology, artificial intelligence technology will be applied in more fields and play an increasingly important role.
[0003] Automated typesetting and layout generation is the key to achieving automated graphic design. It requires arranging the positions and sizes of design elements of various modalities (such as pictures, texts, decorative elements, etc.) according to user-specified requirements, and making the overall layout look beautiful and neat. In related technologies, design elements are arranged by program based on manually defined design rules, and then manually adjusted. This method is inefficient and difficult to flexibly respond to different design tasks; in related technologies, the method based on deep learning can train corresponding models for specific typesetting and design tasks, but it is difficult to generalize to a variety of typesetting and design tasks in reality, and the ability to understand the typesetting requirements described by users in natural language needs to be improved. Summary of the invention
[0004] In order to improve the intelligence and efficiency of automatic layout generation, the present application provides a layout generation method, device, medium and equipment. The technical solution is as follows:
[0005] In a first aspect, the present application provides a layout generation method, the method comprising:
[0006] Obtaining element attribute information corresponding to a layout task and task indication information corresponding to the layout task, wherein the element attribute information represents an attribute of at least one view element, and the task indication information represents a type and condition of the layout task; the type of the layout task is any one of at least one preset layout type;
[0007] Performing text tokenization processing on the task instruction information and the element attribute information to obtain a text sequence;
[0008] The text sequence is input into a layout prediction model, and layout prediction processing is performed on the layout task to obtain first layout information, where the first layout information indicates a layout mode of the at least one view element in a preset view.
[0009] Optionally, the method further includes:
[0010] Get the background image;
[0011] Inputting the background image into an image encoder to perform image feature extraction processing to obtain a first image sequence;
[0012] Inputting the first image sequence into a linear mapping network and performing linear mapping processing to obtain a second image sequence; aligning the second image sequence with the text sequence in a vocabulary space;
[0013] The text sequence and the second image sequence are input into the layout prediction model, and layout prediction processing for the layout task is performed to obtain second layout information, where the second layout information indicates the layout mode of the at least one view element in the background image.
[0014] Optionally, the layout prediction model includes a feature representation module, a content perception module and a layout prediction module, and the step of inputting the text sequence into the layout prediction model, performing layout prediction processing for the layout task, and obtaining the first layout information includes:
[0015] Inputting the text sequence into the feature representation module to perform feature embedding representation processing to obtain a first feature sequence;
[0016] Inputting the first feature sequence into the content perception module, performing content perception processing on the layout task, and obtaining first content feature information;
[0017] Inputting the first content feature information into the layout prediction module, performing layout prediction processing on the layout task, and obtaining a first layout feature sequence;
[0018] The first layout feature sequence is subjected to a reverse text tokenization process to obtain first layout information, where the first layout information is a structured text.
[0019] Optionally, the first content feature information includes a target query feature, a target key feature, and a numerical feature, and the first feature sequence is input into the content perception module to perform content perception processing for the layout task to obtain the first content feature information, including:
[0020] Inputting the first feature sequence into the content perception module and performing normalization processing to obtain a normalized first feature sequence;
[0021] Performing linear transformation processing on the normalized first feature sequence to obtain query features, key features and the numerical features;
[0022] determining a rotational position characteristic of each of the at least one view element;
[0023] The query feature and the key feature are respectively fused with the rotational position feature of each view element to obtain the target query feature and the target key feature.
[0024] Optionally, the first content feature information includes a target query feature, a target key feature, and a numerical feature, and the step of inputting the first content feature information into the layout prediction module to perform layout prediction processing for the layout task to obtain a first layout feature sequence includes:
[0025] Inputting the target query feature and the target key feature into the layout prediction module, performing mask processing, and obtaining a mask query feature and a mask key feature;
[0026] Performing nonlinear transformation processing on the mask query feature and the mask key feature to obtain initial layout features corresponding to the current prediction round;
[0027] The initial layout feature corresponding to the current prediction round and the numerical feature are fused to obtain a first layout feature corresponding to the current prediction round;
[0028] The first layout feature corresponding to the current prediction round and the first feature sequence are concatenated to obtain an input for the next prediction round, and content-aware processing and layout prediction processing are iteratively performed until the first layout feature sequence is obtained.
[0029] Optionally, the performing text tokenization processing on the task instruction information and the element attribute information to obtain a text sequence includes:
[0030] Performing word segmentation processing on the task instruction information in text format to obtain a task text sequence;
[0031] Determine a text sequence corresponding to each view element in the at least one view element from the element attribute information;
[0032] The task text sequence and the text sequence corresponding to each view element are concatenated to obtain the text sequence.
[0033] Optionally, the element attribute information includes bounding box coordinate data of each view element, and the method further includes:
[0034] Normalizing the bounding box coordinate data of each view element to obtain first bounding box coordinate data of each view element;
[0035] Alternatively, the bounding box coordinate data of each view element is truncated by the number of digits to obtain the second bounding box coordinate data of each view element;
[0036] The determining, from the element attribute information, a text sequence corresponding to each view element in the at least one view element further includes:
[0037] updating the element attribute information according to the bounding box coordinate data of each view element or the second bounding box coordinate data of each view element to obtain target element attribute information;
[0038] A text sequence corresponding to each view element in the at least one view element is determined from the target element attribute information.
[0039] Optionally, the method further includes:
[0040] Acquire a first training data set, the first training data set comprising at least one set of first image-text sample data, each set of first image-text sample data comprising a first sample background image and a first description text corresponding to the first sample background image, the first description text representing image semantic features and image geometric features of the corresponding first sample background image;
[0041] Inputting the first sample background image into the image encoder to perform image feature extraction processing to obtain a first sample image sequence;
[0042] Inputting the first sample image sequence into an initial linear mapping network and performing linear mapping processing to obtain a second sample image sequence;
[0043] Performing text tokenization processing on the first description text corresponding to the first sample background image to obtain a first sample text sequence;
[0044] The initial linear mapping network is trained according to the second sample image sequence and the first sample text sequence to obtain the linear mapping network.
[0045] Optionally, the method further includes:
[0046] Acquire a second training data set, the second training data set comprising at least one group of second graphic sample data corresponding to the at least one layout type, each group of second graphic sample data comprising a sample layout image and a second description text corresponding to the sample layout image, the second description text representing a layout mode of at least one sample view element in the corresponding sample layout image;
[0047] Determine a second sample background image corresponding to the sample layout image and sample element attribute information of the at least one sample view element;
[0048] Determine sample task indication information corresponding to the sample layout image;
[0049] Performing text tokenization processing on the sample task instruction information and the sample element attribute information to obtain a second sample text sequence;
[0050] Inputting the second sample background image into an image encoder to perform image feature extraction processing to obtain a third sample image sequence;
[0051] Inputting the third sample image sequence into the linear mapping network and performing linear mapping processing to obtain a fourth sample image sequence; aligning the fourth sample image sequence with the second sample text sequence in the vocabulary space;
[0052] Inputting the second sample text sequence and the fourth sample image sequence into a large language model, performing layout prediction processing, and obtaining sample prediction layout information;
[0053] The large language model is trained according to the sample prediction layout information and the second description text to obtain the layout prediction model.
[0054] In a second aspect, the present application provides a layout generation device, the device comprising:
[0055] A first acquisition module is used to acquire element attribute information corresponding to a layout task and task indication information corresponding to the layout task, wherein the element attribute information represents an attribute of at least one view element, and the task indication information represents a type and condition of the layout task; the type of the layout task is any one of at least one preset layout type;
[0056] A first tokenization module, used for performing text tokenization processing on the task instruction information and the element attribute information to obtain a text sequence;
[0057] The first layout generation module is used to input the text sequence into a layout prediction model, perform layout prediction processing on the layout task, and obtain first layout information, where the first layout information indicates the layout mode of the at least one view element in a preset view.
[0058] In a third aspect, the present application provides a computer-readable storage medium, in which at least one instruction or at least one program is stored, and the at least one instruction or the at least one program is loaded and executed by a processor to implement a layout generation method as described in the first aspect.
[0059] In a fourth aspect, the present application provides a computer device, comprising a processor and a memory, wherein the memory stores at least one instruction or at least one program, and the at least one instruction or the at least one program is loaded and executed by the processor to implement a layout generation method as described in the first aspect.
[0060] In a fifth aspect, the present application provides a computer program product, wherein the computer program product includes computer instructions, and when the computer instructions are executed by a processor, a layout generation method as described in the first aspect is implemented.
[0061] The present application provides a layout generation method, device, medium and equipment, which have the following technical effects:
[0062] The solution provided in the present application provides an end-to-end layout generation method, which can perform layout prediction processing for a layout task based on element attribute information corresponding to the input layout task and task indication information corresponding to the layout task, and obtain first layout information, wherein the element attribute information represents the attributes of at least one view element, the task indication information represents the type and conditions of the layout task, and the layout information indicates the layout method of at least one view element in a preset view, which can effectively improve the intelligence and effectiveness of layout generation.
[0063] The solution provided in this application is based on a layout prediction model, and is capable of processing layout tasks of at least one layout type, thus greatly satisfying the needs of automated graphic design.
[0064] Additional aspects and advantages of the present application will be given in part in the description below, and in part will become apparent from the description below, or will be learned through the practice of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0065] In order to more clearly illustrate the technical solutions and advantages in the embodiments of the present application or the prior art, the drawings required for use in the embodiments or the prior art descriptions are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0066] Figure 1 It is a schematic diagram of an implementation environment of a layout generation method provided in an embodiment of the present application;
[0067] Figure 2 It is a flow chart of a layout generation method provided in an embodiment of the present application;
[0068] Figure 3 It is a schematic diagram of a processing flow of a layout prediction model provided in an embodiment of the present application;
[0069] Figure 4 It is a flowchart of a content-aware processing provided by an embodiment of the present application;
[0070] Figure 5 It is a flow chart of a layout generation method on a background image provided by an embodiment of the present application;
[0071] Figure 6 It is a schematic diagram of an application of layout generation on a background image provided by an embodiment of the present application;
[0072] Figure 7 It is a schematic diagram of the effect of layout generation on a background image provided by an embodiment of the present application;
[0073] 8 (1) to (3) are schematic diagrams showing the effects of target images that meet the task conditions described in natural language provided by an embodiment of the present application;
[0074] Fig. 9 is a schematic diagram of a layout generation device provided in an embodiment of the present application;
[0075] Fig.10 It is a schematic diagram of the hardware structure of a device for implementing a layout generation method provided in an embodiment of the present application. DETAILED DESCRIPTION
[0076] Artificial Intelligence (AI) is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results. In other words, artificial intelligence is a comprehensive technology in computer science that attempts to understand the essence of intelligence and produce a new intelligent machine that can respond in a similar way to human intelligence. Artificial intelligence is to study the design principles and implementation methods of various intelligent machines so that machines have the functions of perception, reasoning and decision-making. Artificial intelligence technology is an interdisciplinary subject that covers a wide range of fields, including both hardware-level technology and software-level technology. Basic artificial intelligence technologies generally include technologies such as sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, big data processing technology, operation / interaction systems, and mechatronics.
[0077] The solution provided in the embodiments of the present application involves technologies such as deep learning (DL) of artificial intelligence.
[0078] Deep learning (DL) is a major research direction in the field of machine learning (ML). It is introduced into machine learning to make it closer to its original goal - artificial intelligence. Deep learning is the inherent laws and representation levels of learning sample data. The information obtained in the learning process is of great help in the interpretation of data such as text, images and sounds. Its ultimate goal is to enable machines to have analytical learning capabilities like humans and to recognize data such as text, images and sounds. Deep learning is a complex machine learning algorithm that has achieved results in speech and image recognition that far exceed previous related technologies. Deep learning has achieved many results in search technology, data mining, machine learning, machine translation, natural language processing, multimedia learning, speech, recommendation and personalization technology, and other related fields. Deep learning enables machines to imitate human activities such as seeing, hearing and thinking, solves many complex pattern recognition problems, and makes great progress in artificial intelligence related technologies.
[0079] The solution provided in the embodiment of the present application can be deployed in the cloud, which also involves cloud technology, etc.
[0080] Cloud technology: refers to a hosting technology that unifies hardware, software, network and other resources in a wide area network or local area network to achieve data computing, storage, processing and sharing. It can also be understood as a general term for network technology, information technology, integration technology, management platform technology and application technology based on the cloud computing business model application, which can form a resource pool and be used on demand, flexible and convenient. The back-end services of the technical network system require a large amount of computing and storage resources, such as video websites, picture websites and more portal websites. With the high development and application of the Internet industry, each item may have its own identification mark in the future, and all need to be transmitted to the back-end system for logical processing. Data of different levels will be processed separately. All kinds of industry data need strong system backing support, so cloud technology needs to be supported by cloud computing. Cloud computing is a computing model that distributes computing tasks on a resource pool composed of a large number of computers, so that various application systems can obtain computing power, storage space and information services as needed. The network that provides resources is called "cloud". The resources in the "cloud" are infinitely expandable in the eyes of users, and can be obtained at any time, used on demand, expanded at any time, and paid for by use. As a cloud computing basic capability provider, a cloud computing resource pool platform will be established, referred to as a cloud platform, generally referred to as Infrastructure as a Service (IaaS), and various types of virtual resources will be deployed in the resource pool for external customers to choose to use. The cloud computing resource pool mainly includes: computing devices (which can be virtualized machines, including operating systems), storage devices, and network devices.
[0081] The embodiments of the present application provide a layout generation method, device, medium and equipment. The technical scheme in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application. Examples of the embodiments are shown in the drawings, where the same or similar numbers throughout represent the same or similar elements or elements with the same or similar functions.
[0082] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or server that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0083] In order to facilitate understanding of the technical solutions described in the embodiments of the present application and the technical effects produced therefrom, the embodiments of the present application explain the relevant professional terms involved:
[0084] Automatic Layout Generation: Automatic Layout Generation aims to generate realistic graphic scenes with elements of different properties, including categories, sizes, positions, and relationships between elements.
[0085] Large Language Model: Large Language Model (LLM) is a deep learning model trained on massive text data. It can not only generate natural language text, but also deeply understand the meaning of text and handle various natural language tasks such as text summarization, question answering, translation, etc.
[0086] Emergent Abilities: Emergent Abilities refer to abilities that suddenly appear in the large model but do not exist in the small model. These abilities include, but are not limited to, common sense reasoning, question answering, translation, mathematical solutions, and summary generation. Emergent abilities cannot be predicted simply by extrapolating the abilities of the small model. They usually appear when the parameter scale and pre-training data volume of the large model reach a certain level, manifesting as a sharp improvement in performance.
[0087] It is understandable that in the specific implementation of the present application, it involves the use of training data, poster data and other related data. When the above embodiments of the present application are applied to specific products or technologies, user permission or consent is required, and the collection, use and processing of relevant data need to comply with relevant laws, regulations and standards of relevant countries and regions.
[0088] See also Figure 1 , which is a schematic diagram of an implementation environment of a layout generation method provided in an embodiment of the present application, such as Figure 1 As shown, the implementation environment may include at least a client 01 and a server 02 .
[0089] Specifically, the client 01 may include devices such as smart phones, desktop computers, tablet computers, laptop computers, vehicle terminals, digital assistants, smart wearable devices, and voice interaction devices, and may also include software running in the device, such as web pages provided by some service providers to users, or applications provided by these service providers to users. Specifically, the client 01 may be used to obtain element attribute information and task indication information input by the user for the layout task, and send the element attribute information and task indication information for the layout task to the server 02 that runs the layout prediction model.
[0090] Specifically, the server 02 may be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms. The server 02 may include a network communication unit, a processor, and a memory, etc. The terminal and the server may be directly or indirectly connected via wired or wireless communication, and this application is not limited here. Specifically, the server 02 may be used to receive element attribute information and task indication information for a layout task sent by the client 01. The server 02 inputs the element attribute information and the task indication information into a running layout prediction model, performs layout prediction processing for the layout task, and obtains first layout information. The server 02 performs rendering processing according to the first layout information to obtain a design view containing at least one view element. Alternatively, the server 02 may send the first layout information to the terminal 01, so that the first layout information is rendered on the terminal 01 side to obtain a design view containing at least one view element.
[0091] The embodiments of the present application can also be implemented in combination with cloud technology. Cloud technology refers to a hosting technology that unifies a series of resources such as hardware, software and network in a wide area network or a local area network to realize the calculation, storage, processing and sharing of data. It can also be understood as a general term for network technology, information technology, integration technology, management platform technology and application technology based on the cloud computing business model application. Cloud technology needs to be supported by cloud computing. Cloud computing is a computing model that distributes computing tasks on a resource pool composed of a large number of computers, so that various application systems can obtain computing power, storage space and information services as needed. The network that provides resources is called a "cloud". Specifically, the server 02 and the database are located in the cloud, and the server 02 can be a physical machine or a virtualized machine.
[0092] A layout generation method provided by this application is introduced below. Figure 2 It is a flowchart of a layout generation method provided by an embodiment of the present application. The present application provides method operation steps as described in the embodiment or flowchart, but may include more or fewer operation steps based on conventional or non-creative labor. The order of steps listed in the embodiment is only one way of executing the steps among many orders, and does not represent the only order of execution. When the actual system or server product is executed, it can be executed in sequence or in parallel according to the method shown in the embodiment or the accompanying drawings (for example, in a parallel processor or multi-threaded processing environment). Please refer to Figure 2 A layout generation method provided in an embodiment of the present application may include the following steps:
[0093] S210: Obtain element attribute information corresponding to the layout task and task indication information corresponding to the layout task, the element attribute information represents the attributes of at least one view element, and the task indication information represents the type and condition of the layout task; the type of the layout task is any one of at least one preset layout type.
[0094] In the embodiment of the present application, the layout task is any one of at least one type of corresponding view layout design tasks, such as poster design, advertising banner design, user interface design, web page design, video thumbnail design, magazine cover design, PPT (Power Point, presentation) view design, etc. In the case where there is no background image for specifying the view layout design, the layout task can be a preset view layout design task on a blank canvas.
[0095] In an embodiment of the present application, the attributes of at least one view element represented by the element attribute information may include element category, text or image content of the element, subordinate relationship between elements, size of the element, etc. In an embodiment of the present application, the view elements in the view typesetting design task can be divided into categories such as title, subtitle, project logo, project, project title, object, text background, decoration, frame and text. The fine-grained classification reflects the design pattern of the view element and also provides semantic information of the view element for layout prediction processing. Among them, the elements in text format, such as title, subtitle, etc., can indicate the importance of text elements at different levels by using hierarchical classification organization. Visual elements include decoration, text background, object and frame, which are respectively used to indicate the layout prediction model to identify semantically important content in decoration, text background, etc.
[0096] In the embodiment of the present application, the task indication information is set by the user and is used to characterize the type and condition of the layout task. The type of the layout task can be any one of the at least one view typesetting tasks mentioned above. The condition of the layout task can be a design requirement for the type of the layout task and at least one view element described in natural language, including but not limited to requirements for design style, location requirements for specific view elements, and size requirements for design views.
[0097] In one embodiment of the present application, an input template for task instruction information of a layout task is provided. The input template can be described as: "Please place a <n>View elements to create<domain_name> . Keeping the number and type of elements unchanged, the result is returned by filling in the following JSON file. The initial JSON file is defined as<masked_JSON> , where each view element is represented by a bounding box with coordinates [let, top, right, bottom], where each coordinate is a consecutive number between 0 and 1. The user constraints are: <constraints>, which should be considered as necessary layout requirements. ", where <n>The specific number of view elements should be filled in.<domain_name> The specific type of layout task should be filled in the <<constraints>>, and the user's specific condition description information should be filled in the <<constraints>>.
[0098] S220: Perform text tokenization processing on the task instruction information and the element attribute information to obtain a text sequence.
[0099] In the embodiment of the present application, the task instruction information and the element attribute information are subjected to text tokenization, that is, the text is tokenized, and the text content in the task instruction information and the element attribute information is divided into tokens (token is the most basic unit for model processing, which can be a word, character, phrase, symbol, etc.), so that the layout prediction model can recognize the semantics and structure of the text. The resulting text sequence is a token sequence.
[0100] In one embodiment of the present application, step S220 may be implemented as follows:
[0101] S221: Perform word segmentation processing on the task instruction information in text format to obtain a task text sequence.
[0102] Specifically, the task instruction information described in natural language may be segmented according to a variety of segmentation granularities, such as segmentation by vocabulary, segmentation by characters, etc.
[0103] S222: Determine a text sequence corresponding to each view element in at least one view element from the element attribute information.
[0104] S223: Concatenate the task text sequence and the text sequence corresponding to each view element to obtain a text sequence.
[0105] The element attribute information can indicate the position of each view element (x i ,y i ), size (h i , w i ), element type C i , text content or image content within an element i , and then the text sequence Lj corresponding to each view element can be clearly represented, where i represents the number of the view element in at least one view element, and j represents the number of the text sequence corresponding to the view element in the final text sequence. Element type C i It is used to mine the association or constraint relationship between different types of elements. The text sequence corresponding to the view element can be shown as formula (1), where N represents the number of at least one view element:
[0106]
[0107] In a feasible implementation, when the shape of the view element does not involve rotation or irregular shape, the attributes such as the position and size of the view element may also be represented by the coordinate data of the bounding box.
[0108] In the above embodiment, the semantics and structure of the input text can be effectively extracted through the word segmentation processing of the task instruction information and the construction of the text sequence corresponding to each view element.
[0109] In one embodiment of the present application, the element attribute information includes bounding box coordinate data of each view element, and the method may further include:
[0110] S224: Normalize the bounding box coordinate data of each view element to obtain first bounding box coordinate data of each view element.
[0111] S225: Alternatively, the bounding box coordinate data of each view element is truncated by the number of digits to obtain second bounding box coordinate data of each view element.
[0112] Therefore, step S222 may also include:
[0113] S2221: updating the element attribute information according to the first bounding box coordinate data of each view element or the second bounding box coordinate data of each view element to obtain the target element attribute information;
[0114] S2222: Determine a text sequence corresponding to each view element in at least one view element from the target element attribute information.
[0115] In one embodiment of the present application, the bounding box coordinate data is normalized with the width and height of the preset view, which helps to improve the resolution of the view design. Each coordinate data value of the bounding box coordinate data is truncated to K decimal places, which can effectively avoid data redundancy and improve the internal processing efficiency of the layout prediction model. In addition, the element category label C i It is represented as a text label related to the task type corresponding to the layout task. For example, when the layout task is a poster design task, the element category label can be represented as text, LOGO, substrate, etc.
[0116] In the above embodiment, by optimizing the text sequence corresponding to each view element, such as normalizing or truncating the number of bits of the bounding box coordinate data, the tokenization process can be simplified and the internal processing efficiency of the layout prediction model can be improved.
[0117] S230: Input the text sequence into a layout prediction model, perform layout prediction processing for the layout task, and obtain first layout information, where the first layout information indicates a layout method of at least one view element in a preset view.
[0118] In the embodiment of the present application, the layout prediction model is an end-to-end framework built on a large language model, which is trained to perform corresponding layout predictions for various view layout design tasks to obtain layout information. Based on the powerful text understanding and emergence capabilities of the large language model, the layout prediction model can be well generalized to a variety of view layout design tasks without changing the model architecture or parameters, and can accurately understand various design requirements described in natural language, improve the intelligence and efficiency of automated layout generation, and meet the design needs of users.
[0119] In an embodiment of the present application, the first layout information indicates the layout of at least one view element in a preset view, and the first layout information may include the relative position of each view element in the preset view, the size of each view element, etc. The preset view may be a default canvas or a blank canvas of a certain size specified in the task instruction information.
[0120] In one embodiment of the present application, the layout prediction model includes a feature representation module, a content perception module, and a layout prediction module, such as Figure 3 As shown, step S230 may be implemented as follows:
[0121] S310: Input the text sequence into a feature representation module to perform feature embedding representation processing to obtain a first feature sequence.
[0122] Specifically, the text sequence is processed by embedding features, which is also called embedding. The discrete token sequence is mapped to a continuous vector space in combination with the preset word table space. The high-dimensional discrete features are converted into low-dimensional continuous features through embedding representation, which helps to extract semantic information and contextual information in the text sequence.
[0123] S320: Input the first feature sequence into a content-aware module to perform content-aware processing for the layout task to obtain first content feature information.
[0124] In an embodiment of the present application, the content perception module of the layout prediction model obtains first content feature information by extracting and converting the first feature sequence. The first content feature information can indicate the attribute characteristics of the view elements corresponding to the layout tasks contained in the first feature sequence, the type characteristics of the layout tasks, and the conditional semantic characteristics of the layout tasks.
[0125] S330: Input the first content feature information into a layout prediction module, perform layout prediction processing for the layout task, and obtain a first layout feature sequence.
[0126] In an embodiment of the present application, a layout prediction module of a layout prediction model predicts attributes such as size, position, and relationship between elements of at least one view element in a preset view by performing nonlinear transformation processing on first content feature information, and obtains a first layout feature sequence representing the prediction result in vector form.
[0127] S340: Perform a reverse text tokenization process on the first layout feature sequence to obtain first layout information, where the first layout information is a structured text.
[0128] In one embodiment of the present application, a first layout feature sequence in vector form is subjected to inverse text tokenization, that is, the vector is converted into a token, and the converted token sequence is further expressed in a structured text format, thereby obtaining first layout information.
[0129] In one embodiment of the present application, the first layout information can be encoded in a format such as XML (Extensible Markup Language) or JSON (JavaScript Object Notation, a lightweight data exchange format), which can effectively improve the output efficiency of the layout prediction model, help the processing efficiency of subsequent view rendering, and improve the readability of the first layout information.
[0130] In the above embodiment, based on the layout prediction model, feature embedding representation processing, content-aware processing, layout prediction processing and inverse text tokenization processing of the input text sequence are implemented, and first layout information indicating the layout method of at least one view element in a preset view is directly output, thereby realizing end-to-end processing for layout tasks and improving the processing efficiency and intuitiveness of view typesetting design tasks.
[0131] In one embodiment of the present application, the content perception model and the layout prediction module of the layout prediction model are obtained by stacking multiple Attention sub-modules (deep learning models based on attention mechanisms), the first content feature information includes target query features, target key features and numerical features, and step S320 can be implemented as follows:
[0132] S321: Input the first feature sequence into the content perception module and perform normalization processing to obtain a normalized first feature sequence.
[0133] Specifically, the first feature sequence output by the feature representation module is subjected to RMS (Root Mean Square) normalization processing, that is, the root mean square is used instead of the standard deviation for normalization.
[0134] S322: Perform linear transformation processing on the normalized first feature sequence to obtain query features, key features, and numerical features.
[0135] The query features, key features, and numerical features correspond to the vector matrices of Query, Key, and Value in the Attention submodule (specifically, the Transform model), respectively.
[0136] S323: Determine a rotational position feature of each view element in at least one view element.
[0137] The rotation position feature indicates the position feature of each view element in the normalized first feature sequence.
[0138] S324: respectively fuse the query feature and the key feature with the rotation position feature of each view element to obtain a target query feature and a target key feature.
[0139] The first query feature and the first key feature are fused with the rotational position feature of each view element, that is, the rotational position feature is encoded into each dimension of the first query feature and the first key feature. The rotational position feature is also called Rotary Position Encoding (RoPE), so that the model can capture the relative position information of each view element in the first feature sequence. In large language models such as LLaMA, it has been proven that RoPE can provide richer position information in natural language processing tasks, thereby improving the performance of the model.
[0140] The first content feature information includes a target query feature, a target key feature and a first numerical feature.
[0141] In the above embodiment, the content perception module based on the self-attention mechanism performs efficient feature extraction on the first feature sequence and integrates the rotation position features to provide richer position information for subsequent processing, thereby improving the effectiveness of subsequent layout prediction.
[0142] In one embodiment of the present application, step S330 may be implemented as follows:
[0143] S331: Input the target query feature and the target key feature into the layout prediction module, perform mask processing, and obtain the mask query feature and the mask key feature.
[0144] In a feasible implementation, the target query features and target key features are masked by causal masking. Causal masking is a masking method in the self-attention mechanism. The causal mask uses a two-dimensional matrix, in which the elements below the diagonal are all 1, indicating that the information before the current position is allowed to be used, and the elements on the diagonal and above are all 0, indicating that the information after the current position is blocked. In the sequence generation task, this masking method ensures that the model generates outputs step by step in the order of the sequence without using future information in advance, that is, it ensures the autoregressive nature of the model.
[0145] S332: Perform nonlinear transformation processing on the mask query features and the mask key features to obtain initial layout features corresponding to the current prediction round.
[0146] Specifically, an activation function may be used to perform nonlinear transformation processing on the mask query features and the mask key features to obtain the initial layout features corresponding to the current prediction round.
[0147] S333: Fusing the initial layout features and the numerical features corresponding to the current prediction round to obtain the first layout features corresponding to the current prediction round.
[0148] The first local feature corresponding to the current prediction round corresponds to the feature representation of the currently predicted token.
[0149] S334: concatenate the first layout feature and the first feature sequence corresponding to the current prediction round to obtain the input of the next prediction round, and iteratively perform content-aware processing and layout prediction processing until the first layout feature sequence is obtained.
[0150] That is, in the layout prediction module of the layout prediction model, the first feature sequence indicating the overall typesetting layout is obtained by predicting the feature representation of the next token.
[0151] In one embodiment of the present application, the content perception module and layout prediction module of the layout prediction model are obtained by stacking multiple Attention sub-modules and multiple multi-layer perceptron sub-modules. Figure 4 shows a stacked Attention submodule and a multi-layer perceptron submodule, such as Figure 4 As shown, in the first multi-layer perceptron submodule, the output of the first Attention submodule (the result obtained by concatenating the first layout feature and the first feature sequence corresponding to the current prediction round as the content perception result) is executed as follows Figure 4 The processing shown includes normalization, upsampling, gating network processing, nonlinear transformation, and downsampling. The multi-layer perceptron submodule is used to apply a nonlinear activation function and a linear projection after the attention submodule to obtain the final first layout feature corresponding to the current prediction round.
[0152] In the above embodiment, the layout prediction module based on the self-attention mechanism predicts the feature representation of the next token to obtain a first feature sequence that can indicate the overall typesetting layout.
[0153] In one embodiment of the present application, the task instruction information corresponding to the layout task may indicate that an image with content needs to be used as the view background, that is, the layout generation of the view elements needs to be performed on the background image. Figure 5 As shown, a layout generation method provided by the present application can be implemented as follows:
[0154] S510: Obtain element attribute information corresponding to the layout task and task indication information corresponding to the layout task, the element attribute information represents the attributes of at least one view element, and the task indication information represents the type and condition of the layout task; the type of the layout task is any one of at least one preset layout type.
[0155] In an embodiment of the present application, the task indication information corresponding to the layout task may further indicate that an image with content is required as the background image of the view, and the task indication information may further represent the layout constraint conditions between the background image and at least one view element.
[0156] In one embodiment of the present application, an input template for task instruction information of a layout task is provided. The input template can be described as: <resolution>Placed on the background <n>View elements to create<domain_name> It is necessary to avoid the imbalance, overlap, misalignment and occlusion of the objects with semantic meaning on the background image and the view elements. While keeping the number and type of elements unchanged, the result is returned by filling in the following JSON file. The initial JSON file is defined as<masked_JSON> , where each view element is represented by a bounding box with coordinates [let, top, right, bottom], where each coordinate is a consecutive number between 0 and 1. The user constraints are: <constraints>, which should be considered as necessary layout requirements. ", where <resolution>Used to determine the background image, <n>The specific number of view elements should be filled in.<domain_name> The specific type of layout task should be filled in the <<constraints>>, and the user's specific condition description information should be filled in the <<constraints>>.
[0157] S520: Perform text tokenization processing on the task instruction information and the element attribute information to obtain a text sequence.
[0158] Step S520 may refer to the aforementioned embodiment and will not be described in detail here.
[0159] S530: Acquire a background image.
[0160] S540: Input the background image into the image encoder to perform image feature extraction processing to obtain a first image sequence.
[0161] The first image sequence can represent the semantic features and geometric features of the background image.
[0162] S550: Input the first image sequence into a linear mapping network and perform linear mapping processing to obtain a second image sequence; the second image sequence is aligned with the text sequence in the vocabulary space.
[0163] In an embodiment of the present application, in order to align the image features of the background image with the text of the text sequence for unified processing in the layout prediction model, the image features in the background image are first extracted using an image encoder, and then the extracted image features are converted into a text sequence using a linear mapping network, that is, the second image sequence is essentially a sequence represented by tokens.
[0164] Specifically, the image encoder can use the Image Encoder part in CLIP (Contrastive Language-Image Pre-Training, a multimodal pre-training neural network) to convert the image into a representation of a feature vector. Each pixel of the background image is regarded as a background image element, and the image sequence corresponding to each background image element in the second image sequence can be shown as formula (2):
[0165]
[0166] Where i represents the number of the background image element. represents the image content of the i-th background image element, and W represents the matrix of linear mapping
[0167] In addition, for the text content in the background image, the text can be extracted and tokenized based on methods such as optical character recognition.
[0168] S560: Input the text sequence and the second image sequence into a layout prediction model, perform layout prediction processing for the layout task, and obtain second layout information, where the second layout information indicates a layout method of at least one view element in the background image.
[0169] Specifically, the feature embedding representation module, content perception module and layout prediction module in the layout prediction model are used to sequentially perform feature embedding representation processing, content perception processing and layout prediction processing on the target sequence obtained by splicing the text sequence and the second image sequence, so as to obtain second layout information indicating the layout mode of at least one view element in the background image. Step S560 can be specifically implemented as follows:
[0170] S561: Concatenate the text sequence and the second image sequence to obtain a target sequence.
[0171] S562: Input the target sequence into the feature representation module, perform feature embedding representation processing, and obtain a second feature sequence.
[0172] S563: Input the second feature sequence into a content-aware module to perform content-aware processing for the layout task to obtain second content feature information.
[0173] S564: Input the second content feature information into a layout prediction module, perform layout prediction processing for the layout task, and obtain a second layout feature sequence.
[0174] S565: Perform a reverse text tokenization process on the second layout feature sequence to obtain second layout information, where the second layout information is a structured text.
[0175] Steps S561 to S565 may refer to the aforementioned embodiment and will not be described in detail here.
[0176] Figure 6 A specific application embodiment is shown, such as Figure 6 As shown, the user only needs to input the background image, the task instruction information-1 indicating the task type, the task instruction information-2 indicating the task condition and the element attribute information to obtain the second layout information represented by the structured text. By rendering the background image in combination with the second layout information, the following can be obtained: Figure 6 The target image is shown.
[0177] In the above embodiment, the features of the background image are input into the layout prediction model, so that the layout tasks with the background image as the view background can be automatically processed, which enriches the types of layout tasks and improves the generalization ability of the model.
[0178] In one embodiment of the present application, in order to improve the training efficiency of the model, a two-stage training process can be adopted, which respectively performs alignment training for the linear mapping network and fine-tuning training for the layout prediction model. The alignment training for the linear mapping network can be implemented as follows:
[0179] S610: Obtain a first training data set, where the first training data set includes at least one group of first image-text sample data, each group of first image-text sample data includes a first sample background image and a first description text corresponding to the first sample background image, and the first description text represents image semantic features and image geometric features of the corresponding first sample background image.
[0180] In a feasible implementation, the first sample background image may be input into a natural language processing tool (such as ChatGPT, Chat Generative Pre-trained Transformer) to perform image description processing to obtain a first description text corresponding to the first sample background image.
[0181] S620: Input the first sample background image into the image encoder to perform image feature extraction processing to obtain a first sample image sequence.
[0182] S630: Input the first sample image sequence into the initial linear mapping network and perform linear mapping processing to obtain a second sample image sequence.
[0183] S640: Perform text tokenization processing on the first description text corresponding to the first sample background image to obtain a first sample text sequence.
[0184] Steps S620 to S640 may refer to the aforementioned embodiment and will not be described in detail here.
[0185] S650: According to the second sample image sequence and the first sample text sequence, the initial linear mapping network is trained to obtain a linear mapping network.
[0186] In a feasible implementation, the second sample image sequence is also a sequence represented by tokens, and the parameters of the initial linear mapping network are adjusted according to the loss data between the second sample image sequence and the first sample text sequence to obtain the linear mapping network.
[0187] Furthermore, the image encoder may also be trained synchronously.
[0188] In the above embodiment, only the linear mapping network is trained for token alignment of images and texts, which can reduce the overall training workload and improve training efficiency.
[0189] In one embodiment of the present application, fine-tuning training for the layout prediction model may be implemented as follows:
[0190] S710: Obtain a second training data set, where the second training data set includes at least one group of second graphic sample data corresponding to at least one layout type, each group of second graphic sample data includes a sample layout image and a second description text corresponding to the sample layout image, and the second description text represents a layout method of at least one sample view element in the corresponding sample layout image.
[0191] S720: Determine a second sample background image corresponding to the sample layout image and sample element attribute information of at least one sample view element.
[0192] S730: Determine sample task instruction information corresponding to the sample layout image.
[0193] In a feasible implementation, a second description text corresponding to the sample layout image and sample task indication information corresponding to the sample layout image are obtained through a natural language processing tool (such as ChatGPT, Chat GenerativePre-trained Transformer) as constraints for the sample layout task in the training phase.
[0194] S740: Perform text tokenization processing on the sample task instruction information and the sample element attribute information to obtain a second sample text sequence.
[0195] S750: Input the second sample background image into the image encoder to perform image feature extraction processing to obtain a third sample image sequence.
[0196] S760: Input the third sample image sequence into a linear mapping network and perform linear mapping processing to obtain a fourth sample image sequence; the fourth sample image sequence is aligned with the second sample text sequence in the vocabulary space.
[0197] S770: Input the second sample text sequence and the fourth sample image sequence into the large language model, perform layout prediction processing, and obtain sample prediction layout information.
[0198] Steps S740 to S770 may refer to the aforementioned embodiments and will not be described in detail here.
[0199] S780: Training a large language model according to the sample prediction layout information and the second description text to obtain a layout prediction model.
[0200] In a feasible implementation, the sample prediction layout information and the second description text are both structured texts, and a variety of evaluation indicators such as content-aware indicators (such as the readability of text-like view elements, the degree of occlusion of salient areas of the background image, etc.) and geometric measurement indicators (such as overlap ratio, alignment, balance and similarity of the overall layout, etc.) can be used to determine the loss data between the sample prediction layout information and the second description text, so as to fine-tune the parameters of the large language model through the loss data to obtain a layout prediction model.
[0201] At least one set of second graphic sample data corresponding to at least one layout type can be covered, so that at least one view typesetting design task can be covered, thereby obtaining a layout prediction model with higher generalization ability.
[0202] In the above embodiment, the two-stage training process can effectively improve the training efficiency of the entire end-to-end processing framework, while also ensuring the processing performance of the model.
[0203] The embodiment of the present application fine-tunes the large language model to give full play to the emergence ability and powerful text understanding ability of the large language model, so that the model can be well generalized to various typesetting design tasks in reality, and automatically generate beautiful and satisfactory typesetting layouts, such as Figure 7 As shown in FIG8 , the rectangular box in the background image represents the layout area corresponding to the view element. As shown in FIG8 (1) to (3), the layout prediction model can understand various design requirements described in natural language and generate layout information that meets the design requirements.
[0204] A layout generation method in an embodiment of the present application provides an end-to-end layout generation method, which can perform layout prediction processing for a layout task based on the element attribute information corresponding to the input layout task and the task indication information corresponding to the layout task, and obtain first layout information, wherein the element attribute information represents the attribute of at least one view element, the task indication information represents the type and condition of the layout task, and the layout information indicates the layout method of at least one view element in a preset view, which can effectively improve the intelligence and effectiveness of layout generation. The solution provided by the present application is based on a layout prediction model, which can handle layout tasks of at least one layout type, and greatly meets the needs of automated graphic design.
[0205] The present application embodiment also provides a layout generation device 900, such as Fig. 9 As shown, the device may include:
[0206] The first acquisition module 910 is used to acquire element attribute information corresponding to a layout task and task indication information corresponding to the layout task, wherein the element attribute information represents an attribute of at least one view element, and the task indication information represents a type and condition of the layout task; the type of the layout task is any one of at least one preset layout type;
[0207] A first tokenization module 920, configured to perform text tokenization processing on the task instruction information and the element attribute information to obtain a text sequence;
[0208] The first layout generation module 930 is used for the first layout generation module, which is used to input the text sequence into the layout prediction model, perform layout prediction processing on the layout task, and obtain first layout information, wherein the first layout information indicates the layout method of the at least one view element in the preset view.
[0209] In one embodiment of the present application, the device may further include:
[0210] The second acquisition module is used to acquire the background image;
[0211] An image feature extraction module, used for inputting the background image into an image encoder, performing image feature extraction processing, and obtaining a first image sequence;
[0212] An image feature alignment module is used to input the first image sequence into a linear mapping network, perform linear mapping processing, and obtain a second image sequence; the second image sequence is aligned with the text sequence in a vocabulary space;
[0213] The second layout generation module is used to input the text sequence and the second image sequence into the layout prediction model, perform layout prediction processing on the layout task, and obtain second layout information, wherein the second layout information indicates the layout method of the at least one view element in the background image.
[0214] In one embodiment of the present application, the layout prediction model includes a feature representation module, a content perception module and a layout prediction module, and the first layout generation module 930 may include:
[0215] A feature embedding representation submodule, used for inputting the text sequence into the feature representation module, performing feature embedding representation processing, and obtaining a first feature sequence;
[0216] a content-aware submodule, configured to input the first feature sequence into the content-aware module, perform content-aware processing on the layout task, and obtain first content feature information;
[0217] a layout prediction submodule, configured to input the first content feature information into the layout prediction module, perform layout prediction processing on the layout task, and obtain a first layout feature sequence;
[0218] The de-tokenization submodule is used to perform de-text tokenization processing on the first layout feature sequence to obtain first layout information, where the first layout information is structured text.
[0219] In one embodiment of the present application, the first content feature information includes a target query feature, a target key feature, and a numerical feature, and the content perception submodule may include:
[0220] a first normalization unit, configured to input the first feature sequence into the content perception module, perform normalization processing, and obtain a normalized first feature sequence;
[0221] A linear transformation unit, used for performing linear transformation processing on the normalized first feature sequence to obtain query features, key features and the numerical features;
[0222] a rotational position feature determining unit, configured to determine a rotational position feature of each view element of the at least one view element;
[0223] The first feature fusion unit is used to fuse the query feature and the key feature with the rotation position feature of each view element to obtain the target query feature and the target key feature.
[0224] In one embodiment of the present application, the first content feature information includes a target query feature, a target key feature, and a numerical feature, and the layout prediction submodule may include:
[0225] A mask unit, used for inputting the target query feature and the target key feature into the layout prediction module, performing mask processing, and obtaining a mask query feature and a mask key feature;
[0226] A non-linear transformation unit, used to perform non-linear transformation processing on the mask query feature and the mask key feature to obtain an initial layout feature corresponding to a current prediction round;
[0227] A second feature fusion unit is used to fuse the initial layout feature corresponding to the current prediction round and the numerical feature to obtain a first layout feature corresponding to the current prediction round;
[0228] An iterative unit is used to concatenate the first layout feature corresponding to the current prediction round and the first feature sequence to obtain an input for the next prediction round, and iteratively perform content-aware processing and layout prediction processing until the first layout feature sequence is obtained.
[0229] In one embodiment of the present application, the first tokenization module 920 may include:
[0230] A word segmentation unit, used for performing word segmentation processing on the task instruction information in text format to obtain a task text sequence;
[0231] an element text sequence determining unit, configured to determine a text sequence corresponding to each view element in the at least one view element from the element attribute information;
[0232] A sequence concatenation unit is used to concatenate the task text sequence with the text sequence corresponding to each view element to obtain the text sequence.
[0233] In one embodiment of the present application, the element attribute information includes the bounding box coordinate data of each view element, and the first tokenization module 920 may further include:
[0234] a second normalization unit, configured to perform normalization processing on the bounding box coordinate data of each view element to obtain first bounding box coordinate data of each view element;
[0235] a bit processing unit, configured to perform bit truncation on the bounding box coordinate data of each view element to obtain second bounding box coordinate data of each view element;
[0236] The element text sequence determination unit also includes:
[0237] an updating subunit, configured to update the element attribute information according to the first bounding box coordinate data of each view element or the second bounding box coordinate data of each view element to obtain target element attribute information;
[0238] The element text sequence determining subunit is used to determine a text sequence corresponding to each view element in the at least one view element from the target element attribute information.
[0239] In one embodiment of the present application, the device may further include:
[0240] A first training data acquisition unit is used to acquire a first training data set, wherein the first training data set includes at least one group of first image-text sample data, each group of first image-text sample data includes a first sample background image and a first description text corresponding to the first sample background image, and the first description text represents image semantic features and image geometric features of the corresponding first sample background image;
[0241] A first sample image sequence determining unit, configured to input the first sample background image into the image encoder, perform image feature extraction processing, and obtain a first sample image sequence;
[0242] A second sample image sequence determining unit, configured to input the first sample image sequence into an initial linear mapping network, perform linear mapping processing, and obtain a second sample image sequence;
[0243] A first sample text sequence determining unit, configured to perform text tokenization processing on the first description text corresponding to the first sample background image to obtain a first sample text sequence;
[0244] The first training unit is used to train the initial linear mapping network according to the second sample image sequence and the first sample text sequence to obtain the linear mapping network.
[0245] In one embodiment of the present application, the device may further include:
[0246] A second training data acquisition unit is used to acquire a second training data set, wherein the second training data set includes at least one group of second graphic sample data corresponding to the at least one layout type, each group of second graphic sample data includes a sample layout image and a second description text corresponding to the sample layout image, and the second description text represents a layout mode of at least one sample view element in the corresponding sample layout image;
[0247] A second sample background image and sample element attribute information determining unit, configured to determine a second sample background image corresponding to the sample layout image and sample element attribute information of the at least one sample view element;
[0248] A sample task indication information determining unit, used to determine the sample task indication information corresponding to the sample layout image;
[0249] A second sample text sequence determining unit, configured to perform text tokenization processing on the sample task indication information and the sample element attribute information to obtain a second sample text sequence;
[0250] A third sample image sequence determining unit, configured to input the second sample background image into an image encoder, perform image feature extraction processing, and obtain a third sample image sequence;
[0251] a fourth sample image sequence determining unit, configured to input the third sample image sequence into the linear mapping network, perform linear mapping processing, and obtain a fourth sample image sequence; the fourth sample image sequence is aligned with the second sample text sequence in a vocabulary space;
[0252] a layout prediction unit, configured to input the second sample text sequence and the fourth sample image sequence into a large language model, perform layout prediction processing, and obtain sample prediction layout information;
[0253] The second training unit is used to train the large language model according to the sample prediction layout information and the second description text to obtain the layout prediction model.
[0254] In the embodiments of the present application, the term "module" or "unit" refers to a computer program or a part of a computer program that has a predetermined function and works together with other related parts to achieve a predetermined goal, and can be implemented in whole or in part by using software, hardware (such as processing circuits or memories) or a combination thereof. Similarly, a processor (or multiple processors or memories) can be used to implement one or more modules or units. In addition, each module or unit can be part of an overall module or unit that includes the function of the module or unit.
[0255] It should be noted that the device provided in the above embodiment, when implementing its functions, is only illustrated by the division of the above functional modules. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. In addition, the device and method embodiments provided in the above embodiment belong to the same concept, and the specific implementation process is detailed in the method embodiment, which will not be repeated here.
[0256] An embodiment of the present application provides a computer device, which includes a processor and a memory, wherein the memory stores at least one instruction or at least one program, and the at least one instruction or the at least one program is loaded and executed by the processor to implement a layout generation method provided in the above method embodiment.
[0257] Fig.10 A schematic diagram of the hardware structure of a device for implementing a layout generation method provided in an embodiment of the present application is shown, and the device may participate in or include the apparatus or system provided in an embodiment of the present application. Fig.10 As shown, the device 10 may include one or more (1002a, 1002b, ..., 1002n are used to illustrate) processors 1002 (the processor 1002 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA), a memory 1004 for storing data, and a transmission device 1006 for communication functions. In addition, it may also include: a display, an input / output interface (I / O interface), a universal serial bus (USB) port (which may be included as one of the ports of the I / O interface), a network interface, a power supply and / or a camera. It can be understood by those skilled in the art that Fig.10 The structure shown is for illustration only and does not limit the structure of the electronic device. Fig.10 More or fewer components as shown, or with Fig.10 Different configurations are shown.
[0258] It should be noted that the one or more processors 1002 and / or other data processing circuits described above may generally be referred to herein as "data processing circuits". The data processing circuits may be embodied in whole or in part as software, hardware, firmware, or any other combination thereof. In addition, the data processing circuit may be a single independent processing module, or may be incorporated in whole or in part into any of the other components in the device 10 (or mobile device). As involved in the embodiments of the present application, the data processing circuit acts as a processor control (e.g., selection of a variable resistor terminal path connected to an interface).
[0259] The memory 1004 can be used to store software programs and modules of application software, such as program instructions / data storage devices corresponding to the methods described in the embodiments of the present application. The processor 1002 executes various functional applications and data processing by running the software programs and modules stored in the memory 1004, that is, to implement the above-mentioned layout generation method. The memory 1004 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 1004 may further include a memory remotely arranged relative to the processor 1002, and these remote memories may be connected to the device 10 via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0260] The transmission device 1006 is used to receive or send data via a network. The specific example of the above network may include a wireless network provided by a communication provider of the device 10. In one example, the transmission device 1006 includes a network adapter (Network Interface Controller, NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 1006 can be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.
[0261] The display may be, for example, a touch screen liquid crystal display (LCD) that may enable a user to interact with a user interface of device 10 (or mobile device).
[0262] An embodiment of the present application also provides a computer-readable storage medium, which can be set in a server to store at least one instruction or at least one program related to a layout generation method in a method embodiment. The at least one instruction or the at least one program is loaded and executed by the processor to implement a layout generation method provided in the above method embodiment.
[0263] Optionally, in this embodiment, the storage medium may be located in at least one of the multiple network servers of the computer network. Optionally, in this embodiment, the storage medium may include, but is not limited to, various media that can store program codes, such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk, or an optical disk.
[0264] The embodiment of the present invention further provides a computer program product or a computer program, wherein the computer program product or the computer program includes computer instructions, and the computer instructions are stored in a computer-readable storage medium. The processor of the computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes a layout generation method provided in the above various optional implementations.
[0265] It should be noted that the above-mentioned sequence of the embodiments of the present application is for description only and does not represent the advantages and disadvantages of the embodiments. The above-mentioned specific embodiments of the present application are described. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0266] Each embodiment in this application is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device, equipment and storage medium embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0267] A person skilled in the art will understand that all or part of the steps to implement the above embodiments may be accomplished by hardware or by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, and the above-mentioned storage medium may be a read-only memory, a disk or an optical disk, etc.
[0268] The above description is only a preferred embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application should be included in the protection scope of the present application.< / n> < / resolution> < / n> < / resolution> < / n> < / n>
Claims
1. A layout generation method, characterized in that: The method comprises: Obtaining element attribute information corresponding to a layout task and task indication information corresponding to the layout task, wherein the element attribute information represents an attribute of at least one view element, and the task indication information represents a type and condition of the layout task; the type of the layout task is any one of at least one preset layout type; Performing text tokenization processing on the task instruction information and the element attribute information to obtain a text sequence; The text sequence is input into a layout prediction model, and layout prediction processing is performed on the layout task to obtain first layout information, where the first layout information indicates a layout mode of the at least one view element in a preset view.
2. The method according to claim 1, characterized in that The method further comprises: Get the background image; Inputting the background image into an image encoder to perform image feature extraction processing to obtain a first image sequence; Inputting the first image sequence into a linear mapping network and performing linear mapping processing to obtain a second image sequence; aligning the second image sequence with the text sequence in a vocabulary space; The text sequence and the second image sequence are input into the layout prediction model, and layout prediction processing for the layout task is performed to obtain second layout information, where the second layout information indicates the layout mode of the at least one view element in the background image.
3. The method according to claim 1, characterized in that The layout prediction model includes a feature representation module, a content perception module and a layout prediction module. The text sequence is input into the layout prediction model, and layout prediction processing for the layout task is performed to obtain first layout information, including: Inputting the text sequence into the feature representation module to perform feature embedding representation processing to obtain a first feature sequence; Inputting the first feature sequence into the content perception module, performing content perception processing on the layout task, and obtaining first content feature information; Inputting the first content feature information into the layout prediction module, performing layout prediction processing on the layout task, and obtaining a first layout feature sequence; The first layout feature sequence is subjected to a reverse text tokenization process to obtain first layout information, where the first layout information is a structured text.
4. The method according to claim 3, characterized in that The first content feature information includes a target query feature, a target key feature, and a numerical feature. The first feature sequence is input into the content perception module to perform content perception processing for the layout task to obtain the first content feature information, including: Inputting the first feature sequence into the content perception module and performing normalization processing to obtain a normalized first feature sequence; Performing linear transformation processing on the normalized first feature sequence to obtain query features, key features and the numerical features; determining a rotational position characteristic of each of the at least one view element; The query feature and the key feature are respectively fused with the rotational position feature of each view element to obtain the target query feature and the target key feature.
5. The method according to claim 3, characterized in that: The first content feature information includes a target query feature, a target key feature, and a numerical feature. The first content feature information is input into the layout prediction module to perform layout prediction processing for the layout task to obtain a first layout feature sequence, including: Inputting the target query feature and the target key feature into the layout prediction module, performing mask processing, and obtaining a mask query feature and a mask key feature; Performing nonlinear transformation processing on the mask query feature and the mask key feature to obtain an initial layout feature corresponding to the current prediction round; The initial layout feature corresponding to the current prediction round and the numerical feature are fused to obtain a first layout feature corresponding to the current prediction round; The first layout feature corresponding to the current prediction round and the first feature sequence are concatenated to obtain an input for the next prediction round, and content-aware processing and layout prediction processing are iteratively performed until the first layout feature sequence is obtained.
6. The method according to claim 1, characterized in that The step of performing text tokenization processing on the task instruction information and the element attribute information to obtain a text sequence includes: Performing word segmentation processing on the task instruction information in text format to obtain a task text sequence; Determine a text sequence corresponding to each view element in the at least one view element from the element attribute information; The task text sequence and the text sequence corresponding to each view element are concatenated to obtain the text sequence.
7. The method according to claim 6, characterized in that The element attribute information includes bounding box coordinate data of each view element, and the method further includes: Normalizing the bounding box coordinate data of each view element to obtain first bounding box coordinate data of each view element; Alternatively, the bounding box coordinate data of each view element is truncated by the number of digits to obtain the second bounding box coordinate data of each view element; The determining, from the element attribute information, a text sequence corresponding to each view element in the at least one view element further includes: updating the element attribute information according to the first bounding box coordinate data of each view element or the second bounding box coordinate data of each view element to obtain target element attribute information; A text sequence corresponding to each view element in the at least one view element is determined from the target element attribute information.
8. The method according to claim 2, characterized in that: The method further comprises: Acquire a first training data set, the first training data set comprising at least one set of first image-text sample data, each set of first image-text sample data comprising a first sample background image and a first description text corresponding to the first sample background image, the first description text representing image semantic features and image geometric features of the corresponding first sample background image; Inputting the first sample background image into the image encoder to perform image feature extraction processing to obtain a first sample image sequence; Inputting the first sample image sequence into an initial linear mapping network and performing linear mapping processing to obtain a second sample image sequence; Performing text tokenization processing on the first description text corresponding to the first sample background image to obtain a first sample text sequence; The initial linear mapping network is trained according to the second sample image sequence and the first sample text sequence to obtain the linear mapping network.
9. The method according to claim 2, characterized in that: The method further comprises: Acquire a second training data set, the second training data set comprising at least one group of second graphic sample data corresponding to the at least one layout type, each group of second graphic sample data comprising a sample layout image and a second description text corresponding to the sample layout image, the second description text representing a layout mode of at least one sample view element in the corresponding sample layout image; Determine a second sample background image corresponding to the sample layout image and sample element attribute information of the at least one sample view element; Determine sample task indication information corresponding to the sample layout image; Performing text tokenization processing on the sample task instruction information and the sample element attribute information to obtain a second sample text sequence; Inputting the second sample background image into an image encoder to perform image feature extraction processing to obtain a third sample image sequence; Inputting the third sample image sequence into the linear mapping network and performing linear mapping processing to obtain a fourth sample image sequence; aligning the fourth sample image sequence with the second sample text sequence in the vocabulary space; Inputting the second sample text sequence and the fourth sample image sequence into a large language model, performing layout prediction processing, and obtaining sample prediction layout information; The large language model is trained according to the sample prediction layout information and the second description text to obtain the layout prediction model.
10. A layout generation device, characterized in that: The device comprises: A first acquisition module is used to acquire element attribute information corresponding to a layout task and task indication information corresponding to the layout task, wherein the element attribute information represents an attribute of at least one view element, and the task indication information represents a type and condition of the layout task; the type of the layout task is any one of at least one preset layout type; A first tokenization module, used for performing text tokenization processing on the task instruction information and the element attribute information to obtain a text sequence; The first layout generation module is used to input the text sequence into a layout prediction model, perform layout prediction processing on the layout task, and obtain first layout information, where the first layout information indicates the layout mode of the at least one view element in a preset view.
11. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores at least one instruction or at least one program, and the at least one instruction or the at least one program is loaded and executed by a processor to implement a layout generation method according to any one of claims 1 to 9.
12. A computer device, characterized in that: The computer device includes a processor and a memory, wherein the memory stores at least one instruction or at least one program, and the at least one instruction or the at least one program is loaded and executed by the processor to implement a layout generation method as described in any one of claims 1 to 9.
13. A computer program product, comprising a computer program, characterized in that When the computer program is executed by an electronic device, the layout generating method according to any one of claims 1 to 9 is implemented.
Citation Information
Cited By
Unified multi-task and multi-field layout generation method and device, equipment and medium
CN120068798A
Condition-based structured layout generation method and device, equipment and storage medium
CN120763987A
Condition-based structured layout generation method, device and equipment and storage medium
CN120763987B
