Page generation method and device
By receiving the initial position information and type information of the page elements, encoding and decoding processing are performed, and the target page layout is generated, which solves the problem that the prior art cannot generate a page layout using any number of elements, and realizes the layout generation of any number of elements.
Patent Information
- Application Number
- CN202210264138.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-17
- Publication Date
- 2025-04-08
- Estimated Expiration
- 2042-03-17
AI Technical Summary
The prior art cannot effectively generate page layouts using any number of elements.
By receiving the initial position information and type information of the page element, the encoding process is performed to generate the element encoding matrix, the position vector is updated according to the type vector, the target position information is decoded and the target page is generated.
It realizes layout generation of any number of elements, improving the flexibility and applicability of page layout.
Smart Images

Figure CN114860232B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present specification relate to the field of computer technology, and in particular to a page generation method. Background Art
[0002] E-commerce consumers have diversified and personalized shopping needs. For diversified and personalized needs, page layout is very important for consumers. Better page layout can attract consumers. Existing page layouts include attribute-conditioned layout generative adversarial networks (Attribute-conditioned Layout GAN), which applies GANs to automatic layout generation. It inputs randomly sampled noise as randomly placed plane polygon elements into the generative model, and inputs three related attributes (expected area, aspect ratio and reading order) for each element to provide specific conditional constraints. The generative model arranges these randomly placed elements according to the design rules learned by the model to generate a layout diagram that meets the conditional constraints; Content-aware Generative Modeling of Graphic Design Layouts also introduces GANs. The model generates layouts by directly generating layout images, and considers the influence of factors such as element semantics, layout style, and image-text ratio on the layout. It encodes the constraints such as visual semantics and text semantics input by users, and inputs them into the generative model together with randomly sampled noise. The generative model generates layout images according to the rules learned by the model. Since the images directly generated by the generative model contain noise, this method also uses image processing algorithms to post-process the generated layout images; the Neural Design Network models the graphic design layout as a graph structure, the elements in the layout are the vertices in the graph structure, and the positional relationship between the elements is the directed edge in the graph structure. Graph Neural Networks (GNNs) are used to capture the dependencies between components and assist in layout generation. The above scheme cannot achieve the task of using any number of elements for layout generation, so a scheme that can input any number of elements for layout is needed. Summary of the invention
[0003] In view of this, an embodiment of this specification provides a page generation method. One or more embodiments of this specification also relate to a page generation device, a computing device, a computer-readable storage medium and a computer program to solve the technical defects existing in the prior art.
[0004] According to a first aspect of an embodiment of this specification, a page generation method is provided, including:
[0005] Receiving a page element, and obtaining initial position information and type information of the page element;
[0006] Encoding the initial position information and the type information to obtain an element encoding matrix, wherein the element encoding matrix includes a type vector and a position vector;
[0007] Update the position vector according to the type vector in the element encoding matrix to obtain data to be decoded;
[0008] The data to be decoded is decoded to obtain target position information, and corresponding page elements are processed according to the target position information to generate a target page.
[0009] According to a second aspect of an embodiment of this specification, a page generation device is provided, including:
[0010] An information acquisition module is configured to receive a page element and acquire initial position information and type information of the page element;
[0011] an encoding module, configured to encode the initial position information and the type information to obtain an element encoding matrix, wherein the element encoding matrix includes a type vector and a position vector;
[0012] A relationship module, configured to update the position vector according to the type vector in the element encoding matrix to obtain data to be decoded;
[0013] The decoding module is configured to decode the data to be decoded to obtain target position information, and process corresponding page elements according to the target position information to generate a target page.
[0014] According to a third aspect of an embodiment of this specification, a computing device is provided, including:
[0015] Memory and processor;
[0016] The memory is used to store computer executable instructions, and the processor is used to execute the computer executable instructions. When the computer executable instructions are executed by the processor, the steps of the above-mentioned page generation method are implemented.
[0017] According to a fourth aspect of the embodiments of this specification, a computer-readable storage medium is provided, which stores computer-executable instructions, and when the instructions are executed by a processor, the steps of the above-mentioned page generation method are implemented.
[0018] According to a fifth aspect of the embodiments of this specification, a computer program is provided, wherein when the computer program is executed in a computer, the computer is caused to execute the steps of the above-mentioned page generation method.
[0019] The embodiments of this specification provide a page generation method and device, wherein the page generation method includes: receiving page elements, and obtaining initial position information and type information of the page elements; encoding the initial position information and the type information to obtain an element encoding matrix, wherein the element encoding matrix includes a type vector and a position vector; updating the position vector according to the type vector in the element encoding matrix to obtain data to be decoded; decoding the data to be decoded to obtain target position information, and processing the corresponding page elements according to the target position information to generate a target page. By receiving any number of page elements, determining the position of the page elements in the page according to the type relationship between the page elements, and then generating a page layout, there is no limit on the number of page elements, and the target page can be generated for the layout of any number of elements. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] Figure 1 is a flow chart of a page generation method provided by an embodiment of this specification;
[0021] Figure 2 is a schematic diagram of a page generation method provided by an embodiment of this specification;
[0022] Figure 3 It is a model training schematic diagram of a page generation method provided by an embodiment of this specification;
[0023] Figure 4 is a process flow chart of a page generation method provided by an embodiment of this specification;
[0024] Figure 5 It is a structural schematic diagram of a page generating device provided by an embodiment of this specification;
[0025] Figure 6 It is a structural block diagram of a computing device provided by an embodiment of this specification. DETAILED DESCRIPTION
[0026] Many specific details are described in the following description to facilitate a full understanding of this specification. However, this specification can be implemented in many other ways than those described herein, and those skilled in the art can make similar generalizations without violating the connotation of this specification, so this specification is not limited to the specific implementation disclosed below.
[0027] The terms used in one or more embodiments of this specification are only for the purpose of describing specific embodiments, and are not intended to limit one or more embodiments of this specification. The singular forms of "a", "said" and "the" used in one or more embodiments of this specification and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used in one or more embodiments of this specification refers to and includes any or all possible combinations of one or more associated listed items.
[0028] It should be understood that although the terms first, second, etc. may be used to describe various information in one or more embodiments of this specification, this information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of one or more embodiments of this specification, the first may also be referred to as the second, and similarly, the second may also be referred to as the first. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".
[0029] First, the terms involved in one or more embodiments of this specification are explained.
[0030] Generative Adversarial Networks (GANs): Generative adversarial networks are a deep generative model that uses the zero-sum game idea in game theory to achieve Nash equilibrium through the game between two neural networks, learn the distribution of real data, and generate new synthetic data. Generative adversarial networks consist of a generative model G and a discriminator D. The generative model G is a generative neural network that receives random noise as input and synthesizes virtual data through this random noise; the discriminator D is a discriminative neural network that takes real data or synthetic data as input and then outputs the probability that the data is real data. During the training process, the goal of the generative model is to generate realistic images as much as possible to deceive the discriminator, while the goal of the discriminator is to correctly distinguish between real data and synthetic data as much as possible. The two compete and continuously optimize to finally reach a Nash equilibrium.
[0031] Conditional Generative Adversarial Nets (cGANs): CGNs input additional information into the generative model and discriminator of the generative adversarial network as additional input layer conditions to control the mode of generated data. The generative model needs to generate realistic images that meet the conditional constraints, and the discriminator needs to determine whether the input sample is real and whether it meets the input conditional information.
[0032] One-hot encoding, also known as one-bit effective encoding, uses an N-bit state register to encode N states. Each state has its own independent register bit, and at any time, only one of them is valid.
[0033] Latent variables are based on the latent variable linear structural model. The idea of variable transformation is introduced for the first time, and the likelihood function and parameter estimation under Box-Cox transformation are given, thereby improving the applicability and accuracy of the previous LISREL model.
[0034] Normal distribution, also known as "normal distribution" or Gaussian distribution, was first obtained by Abraham de Moivre in the asymptotic formula for binomial distribution.
[0035] Sigmoid function: is a common S-shaped function in biology, also known as the S-shaped growth curve. In information science, due to its monotonic and inverse monotonic properties, the Sigmoid function is often used as an activation function of a neural network to map variables between 0 and 1.
[0036] Convolutional Neural Networks (CNN) are a type of feedforward neural networks that include convolution calculations and have a deep structure. They are one of the representative algorithms of deep learning.
[0037] In this specification, a page generation method is provided. This specification also relates to a page generation device, a computing device, a computer-readable storage medium and a computer program, which are described in detail one by one in the following embodiments.
[0038] See also Figure 1 , Figure 1 A flow chart of a page generation method provided according to an embodiment of the present specification is shown, which specifically includes the following steps.
[0039] Step 102: Receive a page element, and obtain initial position information and type information of the page element.
[0040] Among them, the page elements can be elements such as buttons, texts, pictures, etc., for example, the page elements are 1 button, 1 text "Hello", and 1 picture; the initial position information may include information such as the center position of the element, the length and width of the element, for example, the page element is 1 button, the center position of the button can be (x1, y1), and the length and width of the button can be 20 pixels × 20 pixels; the type information can be information representing the corresponding type of the element, for example, it can be divided into buttons, texts, and pictures.
[0041] In practical applications, we can use bounding boxes to represent each element in the layout, and formulate the problem to be solved as finding a better spatial combination of a set of marked borders. A graphic design layout can be represented by a set of {(l 1 ,s 1 ,t 1 ),…,(l N ,s N ,t N )}, where l≡[x c ,y c ], indicating the center coordinates of the design element. s≡[w,h], indicating the width and height of the design element, and t indicating the category of the design component. For example, a mobile UI layout includes buttons, text, images, etc. Figure 2 As shown, in a graphic design layout, each design element is represented by a bounding box. Figure 2 The layout shown contains an image component, a text component, and a button component. These design elements with properties such as position, size, and type together constitute the data representation of the layout.
[0042] For example, the received page elements are 1 button, 1 text "Hello", and 1 picture, and the center position of the button, 1 text "Hello", and 1 picture, the length and width of the elements and other information are obtained, where the center position of the button can be (x1, y1), the length and width of the button can be 20 pixels × 20 pixels, the center position of the text is (x2, y2), the length and width of the bounding box of the text can be 20 pixels × 40 pixels, the center position of the picture is (x3, y3), and the length and width of the bounding box of the picture can be 100 pixels × 200 pixels.
[0043] In practical applications, we can set the maximum number of design elements in a layout to 10. Under this condition, we consistently use 10 component vectors to represent a layout. For layouts with less than 10 components, we use 0 vectors to represent invalid components that do not exist. The specific implementation is as follows.
[0044] After obtaining the initial position information and type information of the page element, the method further includes:
[0045] If the number of the page elements does not satisfy the preset element value, determining the difference between the number of the page elements and the preset element value;
[0046] Default information is generated based on the difference.
[0047] The preset element value may be understood as the maximum number of the above-mentioned design elements, for example, the preset element value is 10; the default information may be the above-mentioned "0 vector".
[0048] For example, the preset element value is 5, and the obtained page elements include 1 button, 1 text "Hello", and 1 picture. The difference between the number of obtained elements and the preset element value is 2, so a 0 vector is generated to fill the empty element position.
[0049] The embodiments of this specification can generate a page layout according to any number of elements within a preset element value by supplementing zero vectors at the positions of missing elements, thereby improving usability and universality.
[0050] Step 104: Encode the initial position information and the type information to obtain an element encoding matrix, wherein the element encoding matrix includes a type vector and a position vector.
[0051] The type vector may be a vector obtained by encoding the type information; and the position information may be a vector obtained by encoding the position information.
[0052] In practical applications, the design layout containing the initial category information and latent variables is taken as input, which is represented as {(z 1 , t 1 ),…,(z N , t N )}, where z represents the potential variables randomly sampled from the Gaussian distribution, such as the center position and length and width information, and t represents the one-hot encoding of the element category in the layout, which serves as a constraint for layout generation. 1 , t 1 ),…,(z N , t N )} as input, the encoding module composed of multiple fully connected layers encodes the input type parameters and latent vectors.
[0053] For example, the preset element value is 3, and the obtained page elements include 1 button, 1 text "Hello", and 1 picture. ((l 1 ,s 1 , t1 ), (l 2 ,s 2 , t 2 ), (l 3 ,s 3 , t 3 )}, then for {(l 1 ,s 1 , t 1 ), (l 2 ,s 2 , t 2 ), (l 3 ,s 3 , t 3 )} for encoding.
[0054] Furthermore, when there is a difference between the acquired element and the preset element value, the code value of the invalid element needs to be reset, and the specific implementation method is as follows.
[0055] Specifically, the encoding process of the initial position information and the type information to obtain an element encoding matrix includes:
[0056] Encoding the initial position information, the type information, and the default information to obtain an initial coding matrix, wherein the code corresponding to the default information in the initial coding matrix carries a default mark;
[0057] The initial coding matrix is initialized to obtain an element coding matrix.
[0058] The default mark can be understood as a mark of a 0 vector for a non-existent page element; and initialization can be understood as an operation of resetting the encoded default information.
[0059] In actual applications, when the number of elements is less than the preset element value, the value 0 is used to represent the non-existent invalid elements to maintain consistency within the model architecture and facilitate actual training. However, the value 0 used to represent invalid elements in the layout will be modified to a non-zero value in the Batch Normalization layer after the encoding module. After that, when the invalid elements are input into the relationship module, they will still be regarded as existing valid elements. To solve this problem, we introduced element masks into the model, which can reset the values of these non-existent invalid components to 0 after the Batch Normalization layer. This enables the model to correctly adjust the relationship between all elements and realize layout design with different numbers of elements.
[0060] For example, the preset element value is 5, and the obtained page elements include 1 button, 1 text "Hello", and 1 picture. The difference between the number of elements obtained and the preset element value is 2, so a 0 vector is generated to fill the vacant element position. After encoding, the 0 vector may become a non-zero vector, such as N and M, where N and M carry default tags; then {(l 1 ,s 1 , t 1 ), (l 2 ,s 2 , t 2 ), (l 3 ,s 3 , t 3 ), N, M} for initialization, we can get
[0061] Specifically, the initializing the initial coding matrix to obtain an element coding matrix includes:
[0062] The codes carrying default marks in the initial coding matrix are set to default values to obtain an element coding matrix.
[0063] Using the above example, for {(l 1 ,s 1 , t 1 ), (l 2 ,s 2 , t 2 ), (l 3 ,s 3 , t 3 ), N, M} are initialized, then N and M are reset to the 0 vector, that is, initialization is performed.
[0064] After encoding the elements, the embodiments of this specification encode the zero vectors of the element positions that do not originally exist into other vectors. By restoring these other vectors to zero vectors, layout problems are avoided, so that any number of elements can be laid out and the accuracy of the layout is improved.
[0065] Step 106: Update the position vector according to the type vector in the element encoding matrix to obtain data to be decoded.
[0066] Among them, updating the position vector according to the type vector in the element encoding matrix can be understood as determining the position relationship of the page elements by judging the type of the element and the types of other elements. For example, text A is a title type and text B is a text type, then the relationship between text A and text B is roughly: text A is above text B.
[0067] In practice, a relation module implemented by a self-attention mechanism is used to embed the features of each layout element as a function of its spatial environment, i.e., its relationship with all other elements in the layout, so as to jointly adjust the relationships between all elements.
[0068] Specifically, updating the position vector according to the type vector in the element encoding matrix to obtain the data to be decoded includes:
[0069] Select the i-th page element, where the initial value of i is 1 and i is less than or equal to the number of the page elements;
[0070] Obtaining a layout weight of the i-th page element according to type vectors of other page elements except the i-th page element and the type vector of the i-th page element, wherein the layout weight is a weight of the influence of the other page elements except the i-th page element on the i-th page element;
[0071] The position vector of the i-th page element is updated according to the layout weight of the i-th page element, and i is incremented by 1, and the i-th page element is continuously selected.
[0072] For example, the preset element value is 5, and the obtained page elements include 1 button, 1 text "Hello", and 1 picture. The difference between the number of elements obtained and the preset element value is 2, so a 0 vector is generated to fill the empty element position. According to the relationship between t1, t2 and t3 respectively, the layout weights of the influence of buttons and texts on pictures can be generated. According to the relationship between t1, t3 and t2 respectively, the layout weights of the influence of buttons and pictures on texts can be generated. According to the relationship between t3, t2 and t1 respectively, the layout weights of the influence of text and pictures on buttons can be generated. According to the layout weights of pictures, texts and buttons, (l1, s1), (l2, s2) and (l3, s3) can be updated.
[0073] The embodiments of this specification determine the position and size of elements in the layout by the types of elements, and can generate a layout in which the elements are arranged reasonably and comply with the design rules.
[0074] Step 108: Decode the data to be decoded to obtain target position information, and process corresponding page elements according to the target position information to generate a target page.
[0075] The target page may be an application page, a web page, or a page of a magazine or book.
[0076] In practical applications, a decoding module is used to decode the relationship between each element in the layout. The decoding module consists of multiple fully connected layers. The data to be decoded is passed to the fully connected layer with a sigmoid activation function, and the optimized layout (l, s, t)≡{(l 1 ,s 1 , t 1 ),…,(l N ,s N , t N )}.
[0077] Specifically, the decoding of the to-be-decoded data to obtain target position information includes:
[0078] The data to be decoded is decoded to obtain target side length information and target coordinate information.
[0079] Using the above example, the data to be decoded is Decoding the data to be decoded can obtain (l1, s1), (l2, s2), (l3, s3), that is, (x1, y1), (w1, h1), (x2, y2), (w2, h2), (x3, y3), (w3, h3).
[0080] Further, processing corresponding page elements according to the target location information to generate a target page includes:
[0081] The side length of the corresponding page element is updated according to the target side length information, and the position of the corresponding page element is updated according to the target coordinate information to generate a target page.
[0082] Continuing with the above example, we have obtained (l1, s1), (l2, s2), and (l3, s3), namely (x1, y1), (w1, h1), (x2, y2), (w2, h2), (x3, y3), and (w3, h3). The length, width, and center position of the button are determined according to (x1, y1) and (w1, h1); the length, width, and center position of the text are determined according to (x2, y2) and (w2, h2); and the length, width, and center position of the image are determined according to (x3, y3) and (w3, h3).
[0083] The embodiment of the present specification receives any number of page elements, determines the positions of the page elements in the page according to the type relationships between the page elements, and then generates a page layout, thereby achieving no limit on the number of page elements and being able to generate a target page for the layout of any number of elements.
[0084] See also Figure 2 , Figure 2is a schematic diagram of a page generation method provided by an embodiment of the present specification, the method of the embodiment of the present specification is applied to a generation model, the generation model includes an encoding module, a relationship module and a decoding module;
[0085] The encoding module receives the page element and obtains the initial position information and type information of the page element, and
[0086] Encoding the initial position information and the type information to obtain an element encoding matrix, wherein the element encoding matrix includes a type vector and a position vector;
[0087] The relationship module updates the position vector according to the type vector in the element encoding matrix to obtain data to be decoded;
[0088] The decoding module decodes the data to be decoded to obtain target position information, and processes corresponding page elements according to the target position information to generate a target page.
[0089] In practical applications, the generative model consists of an encoding module, a relation module, and a decoding module. Figure 3 , first, the generative model converts (z, t) ≡ {(z 1 , t 1 ),…,(z N , t N )} as input, the encoding module composed of multiple fully connected layers encodes the input type parameters and latent vectors. Then, the relationship module implemented by the self-attention mechanism is used to embed the characteristics of each layout element as a function of its spatial environment, that is, its relationship with all other elements in the layout, so as to jointly adjust the relationship between all elements. After the relationship module, the decoding module is used to decode the relationship between each element in the layout. The decoding module consists of multiple fully connected layers. Finally, the data is passed to the fully connected layer with a sigmoid activation function, and the optimized layout (l,s,t)≡{(l 1 ,s 1 ,t 1 ),…,(l N ,s N ,t N )}.
[0090] Further, see Figure 2 , the generation model also includes a mask module;
[0091] The encoding module encodes the initial position information, the type information and the default information to obtain an initial encoding matrix, wherein the code corresponding to the default information in the initial encoding matrix carries a default mark;
[0092] The mask module initializes the initial coding matrix to obtain an element coding matrix.
[0093] In actual applications, when the number of elements is less than the preset element value, the value 0 is used to represent the non-existent invalid elements to maintain consistency within the model architecture and facilitate actual training. However, the value 0 used to represent invalid elements in the layout will be modified to a non-zero value in the Batch Normalization layer after the encoding module. After that, when the invalid elements are input into the relationship module, they will still be regarded as existing valid elements. To solve this problem, we introduced element masks into the model, which can reset the values of these non-existent invalid components to 0 after the Batch Normalization layer. This enables the model to correctly adjust the relationship between all elements and realize layout design with different numbers of elements.
[0094] Furthermore, the method of the embodiment of this specification also includes the step of training the generation model, including:
[0095] Inputting the page element into the generation model to obtain the target location information;
[0096] Inputting the target position information into a first discriminator to obtain the global layout authenticity of the target page;
[0097] The generation model is parameterized according to the global layout authenticity to obtain a first generation model.
[0098] Among them, the global layout authenticity can be understood as distinguishing the generated layout from the real layout based on the position and size parameters of the page elements.
[0099] In practical applications, see Figure 3 , the first discriminator transforms a set of design elements (l,s,t)≡{(l 1 ,s 1 ,t 1 ),…,(l N ,s N ,t N )} as input, the encoding module composed of multiple fully connected layers encodes the input parameters and provides the result to the relationship module. The output of the relationship module is passed to the decoding module. The decoding module is followed by a maximum pooling layer and a fully connected layer with a sigmoid activation function, which is used to predict whether the output layout is real.
[0100] Furthermore, the method of the embodiment of this specification also includes the step of training the first generation model, including:
[0101] Inputting the page element into the first generation model to obtain the target location information;
[0102] Inputting the target position information into a second discriminator to obtain the authenticity of the local layout of the target page;
[0103] The parameters of the first generation model are adjusted according to the local layout authenticity to obtain a second generation model.
[0104] Among them, local layout authenticity can be understood as distinguishing the generated layout from the real layout based on the visual attributes in the layout.
[0105] In practical applications, see Figure 3 The second discriminator distinguishes the generated layout from the real layout by learning the visual attributes in the layout. It is good at distinguishing at the local level. The discriminator consists of a differentiable wireframe rendering layer and a convolutional neural network (CNN). The wireframe rendering layer uses the input layout parameters (l, s, t) to generate a layout wireframe diagram and pass it to CNN. CNN consists of two convolutional layers and two fully connected layers with sigmoid activation functions, and finally outputs the probability that the layout is the real layout.
[0106] Furthermore, the confrontation between the generative model and the discriminator in the generative adversarial network will produce adversarial loss. The adversarial loss of the two discriminators is calculated using the formula It is represented by, where l, s, t are the true layout parameters and the corresponding component categories, D represents the discriminator, and G represents the generation model.
[0107] In addition, the idea of conditional generative adversarial network is used to input the type of design elements into the model as a constraint condition, with the goal of generating a reasonable layout that matches the initial type parameters. In addition to distinguishing whether the input layout is real, the discriminator also needs to judge whether the current layout matches the element category condition, and a penalty is imposed on mismatching layouts. Therefore, this solution introduces a conditional loss function: in, is the true layout parameter and the element category that does not match it. This forces the discriminator to better learn the relationship between element type and layout design, and guides the generative model to generate a layout that better meets the conditional constraints. The above loss function forces the discriminator to output a discriminant value of 0 when encountering a true layout and an inconsistent category condition.
[0108] In practical applications, the geometric parameters and element categories of the actual layout are shuffled and input into the discriminator to optimize the discriminator. The final loss function of the discriminator can be expressed as express:
[0109] Furthermore, the generative model will produce the following formula when trying to deceive the discriminator: The adversarial loss shown here will encourage the generative model to strive to generate layouts that are similar to the real layout.
[0110] The embodiment of this specification provides a page generation method, which includes: receiving a page element, and obtaining the initial position information and type information of the page element; encoding the initial position information and the type information to obtain an element encoding matrix, wherein the element encoding matrix includes a type vector and a position vector; updating the position vector according to the type vector in the element encoding matrix to obtain data to be decoded; decoding the data to be decoded to obtain target position information, and processing the corresponding page element according to the target position information to generate a target page. By receiving any number of page elements, determining the position of the page element in the page according to the type relationship between each page element, and then generating a page layout, there is no limit on the number of page elements, and the target page can be generated for the layout of any number of elements.
[0111] The following combination Figure 4 , taking the application of the page generation method provided in this specification in the server as an example, the page generation method is further described. Figure 4 A process flow chart of a page generation method provided by an embodiment of the present specification is shown, which specifically includes the following steps.
[0112] Step 402: The server receives a page element, and obtains initial position information and type information of the page element.
[0113] Step 404: The server determines whether the number of the page elements is less than the preset element value. If yes, execute steps 406 and 408. If no, execute step 408.
[0114] Step 406: The server determines the difference between the number of the page elements and the preset element value, and generates default information according to the difference.
[0115] Step 408: The server encodes the initial position information and the type information to obtain an element encoding matrix.
[0116] Step 410: The server updates the position vector according to the type vector in the element encoding matrix to obtain data to be decoded.
[0117] Step 412: The server decodes the data to be decoded to obtain target location information.
[0118] Step 414: The server processes corresponding page elements according to the target location information to generate a target page.
[0119] The embodiments of this specification receive any number of page elements, determine the positions of the page elements in the page according to the type relationships between the page elements, and then generate a page layout, thereby achieving no limit on the number of page elements and being able to generate a target page for the layout of any number of elements.
[0120] Corresponding to the above method embodiment, this specification also provides a page generation device embodiment, Figure 5 FIG. 1 is a schematic diagram showing the structure of a page generation device provided by an embodiment of the present specification. Figure 5 As shown, the device comprises:
[0121] The information acquisition module 502 is configured to receive a page element and acquire initial position information and type information of the page element;
[0122] The encoding module 504 is configured to encode the initial position information and the type information to obtain an element encoding matrix, wherein the element encoding matrix includes a type vector and a position vector;
[0123] A relationship module 506 is configured to update the position vector according to the type vector in the element encoding matrix to obtain data to be decoded;
[0124] The decoding module 508 is configured to decode the data to be decoded to obtain target position information, and process corresponding page elements according to the target position information to generate a target page.
[0125] Furthermore, the information acquisition module 502 is further configured to:
[0126] If the number of the page elements does not satisfy the preset element value, determining the difference between the number of the page elements and the preset element value;
[0127] Default information is generated based on the difference.
[0128] Furthermore, the encoding module 504 is further configured to:
[0129] Encoding the initial position information, the type information, and the default information to obtain an initial coding matrix, wherein the code corresponding to the default information in the initial coding matrix carries a default mark;
[0130] The initial coding matrix is initialized to obtain an element coding matrix.
[0131] Furthermore, the encoding module 504 is further configured to:
[0132] The codes carrying default marks in the initial coding matrix are set to default values to obtain an element coding matrix.
[0133] Furthermore, the relationship module 506 is further configured to:
[0134] Select the i-th page element, where the initial value of i is 1 and i is less than or equal to the number of the page elements;
[0135] Obtaining a layout weight of the i-th page element according to type vectors of other page elements except the i-th page element and the type vector of the i-th page element, wherein the layout weight is a weight of the influence of the other page elements except the i-th page element on the i-th page element;
[0136] The position vector of the i-th page element is updated according to the layout weight of the i-th page element, and i is incremented by 1, and the i-th page element is continuously selected.
[0137] Furthermore, the decoding module 508 is further configured to:
[0138] The data to be decoded is decoded to obtain target side length information and target coordinate information.
[0139] Furthermore, the decoding module 508 is further configured to:
[0140] The side length of the corresponding page element is updated according to the target side length information, and the position of the corresponding page element is updated according to the target coordinate information to generate a target page.
[0141] Further, the page generation device is applied to a generation model, and the generation model includes an encoding module, a relationship module and a decoding module;
[0142] The encoding module receives the page element and obtains the initial position information and type information of the page element, and
[0143] Encoding the initial position information and the type information to obtain an element encoding matrix, wherein the element encoding matrix includes a type vector and a position vector;
[0144] The relationship module updates the position vector according to the type vector in the element encoding matrix to obtain data to be decoded;
[0145] The decoding module decodes the data to be decoded to obtain target position information, and processes corresponding page elements according to the target position information to generate a target page.
[0146] Furthermore, the generation model also includes a mask module;
[0147] The encoding module encodes the initial position information, the type information and the default information to obtain an initial encoding matrix, wherein the code corresponding to the default information in the initial encoding matrix carries a default mark;
[0148] The mask module initializes the initial coding matrix to obtain an element coding matrix.
[0149] The page generating device further includes a first training module, which is configured to:
[0150] Inputting the page element into the generation model to obtain the target location information;
[0151] Inputting the target position information into a first discriminator to obtain the global layout authenticity of the target page;
[0152] The generation model is parameterized according to the global layout authenticity to obtain a first generation model.
[0153] The page generating device further includes a second training module, which is configured to:
[0154] Inputting the page element into the first generation model to obtain the target location information;
[0155] Inputting the target position information into a second discriminator to obtain the authenticity of the local layout of the target page;
[0156] The parameters of the first generation model are adjusted according to the local layout authenticity to obtain a second generation model.
[0157] The embodiment of the present specification provides a page generation device, which receives page elements and obtains initial position information and type information of the page elements; encodes the initial position information and the type information to obtain an element encoding matrix, wherein the element encoding matrix includes a type vector and a position vector; updates the position vector according to the type vector in the element encoding matrix to obtain data to be decoded; decodes the data to be decoded to obtain target position information, and processes the corresponding page elements according to the target position information to generate a target page. By receiving any number of page elements, determining the position of the page elements in the page according to the type relationship between the page elements, and then generating a page layout, there is no limit on the number of page elements, and the target page can be generated for the layout of any number of elements.
[0158] The above is a schematic scheme of a page generation device of this embodiment. It should be noted that the technical scheme of the page generation device and the technical scheme of the above page generation method belong to the same concept, and the details not described in detail in the technical scheme of the page generation device can be referred to the description of the technical scheme of the above page generation method.
[0159] Figure 6 The block diagram of a computing device 600 according to an embodiment of the present specification is shown. The components of the computing device 600 include but are not limited to a memory 610 and a processor 620. The processor 620 is connected to the memory 610 via a bus 630, and the database 650 is used to store data.
[0160] The computing device 600 also includes an access device 640 that enables the computing device 600 to communicate via one or more networks 660. Examples of these networks include a public switched telephone network (PSTN), a local area network (LAN), a wide area network (WAN), a personal area network (PAN), or a combination of communication networks such as the Internet. The access device 640 may include one or more of any type of network interface (e.g., a network interface card (NIC)) whether wired or wireless, such as an IEEE 802.11 wireless local area network (WLAN) wireless interface, a World Wide Interoperability for Microwave Access (Wi-MAX) interface, an Ethernet interface, a universal serial bus (USB) interface, a cellular network interface, a Bluetooth interface, a near field communication (NFC) interface, and the like.
[0161] In one embodiment of the present specification, the above components of the computing device 600 and Figure 6 Other components not shown in the figure may also be connected to each other, for example, via a bus. It should be understood that Figure 6 The computing device structure block diagram shown is only for the purpose of illustration, and is not intended to limit the scope of this specification. Those skilled in the art can add or replace other components as needed.
[0162] The computing device 600 may be any type of stationary or mobile computing device, including a mobile computer or mobile computing device (e.g., a tablet computer, a personal digital assistant, a laptop computer, a notebook computer, a netbook, etc.), a mobile phone (e.g., a smart phone), a wearable computing device (e.g., a smart watch, smart glasses, etc.), or other types of mobile devices, or a stationary computing device such as a desktop computer or PC. The computing device 600 may also be a mobile or stationary server.
[0163] The processor 620 is used to execute the following computer executable instructions, which implement the steps of the above-mentioned page generation method when executed by the processor.
[0164] The above is a schematic scheme of a computing device of this embodiment. It should be noted that the technical scheme of the computing device and the technical scheme of the above-mentioned page generation method belong to the same concept, and the details not described in detail in the technical scheme of the computing device can be referred to the description of the technical scheme of the above-mentioned page generation method.
[0165] An embodiment of the present specification further provides a computer-readable storage medium storing computer-executable instructions, which can implement the steps of the above-mentioned page generation method when executed by a processor.
[0166] The above is a schematic scheme of a computer-readable storage medium of this embodiment. It should be noted that the technical scheme of the storage medium and the technical scheme of the above-mentioned page generation method belong to the same concept, and the details not described in detail in the technical scheme of the storage medium can be referred to the description of the technical scheme of the above-mentioned page generation method.
[0167] An embodiment of the present specification further provides a computer program, wherein when the computer program is executed in a computer, the computer is caused to execute the steps of the above-mentioned page generation method.
[0168] The above is a schematic scheme of a computer program of this embodiment. It should be noted that the technical scheme of the computer program and the technical scheme of the above-mentioned page generation method belong to the same concept, and the details not described in detail in the technical scheme of the computer program can be referred to the description of the technical scheme of the above-mentioned page generation method.
[0169] The above is a description of a specific embodiment of the specification. 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.
[0170] The computer instructions include computer program codes, which may be in source code form, object code form, executable files or some intermediate forms, etc. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium, etc. It should be noted that the content contained in the computer-readable medium may be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media do not include electric carrier signals and telecommunication signals.
[0171] It should be noted that, for the above-mentioned method embodiments, for the sake of simplicity of description, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the embodiments of this specification are not limited by the order of the actions described, because according to the embodiments of this specification, some steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the embodiments of this specification.
[0172] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0173] The preferred embodiments of this specification disclosed above are only used to help explain this specification. The optional embodiments do not describe all the details in detail, nor do they limit the invention to only the specific implementation methods described. Obviously, many modifications and changes can be made according to the content of the embodiments of this specification. This specification selects and specifically describes these embodiments in order to better explain the principles and practical applications of the embodiments of this specification, so that technicians in the relevant technical field can well understand and use this specification. This specification is only limited by the claims and their full scope and equivalents.
Claims
1. A page generation method, comprising: Receiving a page element, and obtaining initial position information and type information of the page element; Encoding the initial position information and the type information to obtain an element encoding matrix, wherein the element encoding matrix includes a type vector and a position vector, the type vector is a vector after the type information is encoded, and the position vector is a vector after the position information is encoded; The method includes: updating the position vector according to the type vector in the element encoding matrix to obtain data to be decoded, including: selecting the i-th page element, wherein the initial value of i is 1, and i is less than or equal to the number of the page elements; obtaining the layout weight of the i-th page element according to the type vectors of the other page elements except the i-th page element and the type vector of the i-th page element, wherein the layout weight is the weight of the influence of the other page elements except the i-th page element on the i-th page element; updating the position vector of the i-th page element according to the layout weight of the i-th page element, and increasing i by 1, and continuing to select the i-th page element; The data to be decoded is decoded to obtain target position information, and corresponding page elements are processed according to the target position information to generate a target page.
2. The method according to claim 1, after obtaining the initial position information and type information of the page element, further comprises: If the number of the page elements does not satisfy the preset element value, determining the difference between the number of the page elements and the preset element value; Default information is generated based on the difference.
3. According to the method of claim 2, the encoding process of the initial position information and the type information to obtain an element encoding matrix comprises: Encoding the initial position information, the type information, and the default information to obtain an initial coding matrix, wherein the code corresponding to the default information in the initial coding matrix carries a default mark; The initial coding matrix is initialized to obtain an element coding matrix.
4. The method according to claim 3, wherein initializing the initial coding matrix to obtain an element coding matrix comprises: The codes carrying default marks in the initial coding matrix are set to default values to obtain an element coding matrix.
5. The method according to claim 1, wherein decoding the data to be decoded to obtain target location information comprises: The data to be decoded is decoded to obtain target side length information and target coordinate information.
6. The method according to claim 5, wherein processing corresponding page elements according to the target location information to generate a target page comprises: The side length of the corresponding page element is updated according to the target side length information, and the position of the corresponding page element is updated according to the target coordinate information to generate a target page.
7. The method according to claim 1, wherein the method is applied to a generative model, wherein the generative model comprises an encoding module, a relation module and a decoding module; The encoding module receives the page element and obtains the initial position information and type information of the page element, and The initial position information and the type information are encoded to obtain an element encoding matrix, where: The element encoding matrix includes a type vector and a position vector; The relationship module updates the position vector according to the type vector in the element encoding matrix to obtain data to be decoded; The decoding module decodes the data to be decoded to obtain target position information, and processes corresponding page elements according to the target position information to generate a target page.
8. The method according to claim 7, wherein the generation model further comprises a mask module; The encoding module encodes the initial position information, the type information and the default information to obtain an initial encoding matrix, wherein: The code corresponding to the default information in the initial coding matrix carries a default mark; The mask module initializes the initial coding matrix to obtain an element coding matrix.
9. The method according to claim 7, further comprising the step of training the generative model, comprising: Inputting the page element into the generation model to obtain the target location information; Inputting the target position information into a first discriminator to obtain the global layout authenticity of the target page; The generation model is parameterized according to the global layout authenticity to obtain a first generation model.
10. The method according to claim 9, further comprising the step of training the first generation model, comprising: Inputting the page element into the first generation model to obtain the target location information; Inputting the target position information into a second discriminator to obtain the authenticity of the local layout of the target page; The parameters of the first generation model are adjusted according to the local layout authenticity to obtain a second generation model.
11. A page generating device, comprising: An information acquisition module is configured to receive a page element and acquire initial position information and type information of the page element; an encoding module, configured to encode the initial position information and the type information to obtain an element encoding matrix, wherein the element encoding matrix includes a type vector and a position vector, the type vector is a vector after the type information is encoded, and the position vector is a vector after the position information is encoded; The relationship module is configured to update the position vector according to the type vector in the element encoding matrix to obtain the data to be decoded, including: selecting the i-th page element, wherein the initial value of i is 1, and i is less than or equal to the number of the page elements; obtaining the layout weight of the i-th page element according to the type vectors of the other page elements except the i-th page element and the type vector of the i-th page element, wherein the layout weight is the weight of the influence of the other page elements except the i-th page element on the i-th page element; updating the position vector of the i-th page element according to the layout weight of the i-th page element, and increasing i by 1, and continuing to select the i-th page element; The decoding module is configured to decode the data to be decoded to obtain target position information, and process corresponding page elements according to the target position information to generate a target page.
12. A computing device comprising: Memory and processor; The memory is used to store computer executable instructions, and the processor is used to execute the computer executable instructions. When the computer executable instructions are executed by the processor, the steps of the page generation method according to any one of claims 1 to 10 are implemented.
13. A computer-readable storage medium storing computer-executable instructions, wherein the computer-executable instructions, when executed by a processor, implement the steps of the page generation method according to any one of claims 1 to 10.
Citation Information
Patent Citations
An element layout method, device and equipment and a storage medium
CN109901835A
Information processing method and device
CN110134464A