A global collaborative layout generation system and method based on particle swarm optimization
Patent Information
- Application Number
- CN202610980498.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-02
- Publication Date
- 2026-09-15
Smart Images

Figure CN122760751A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of computer vision and digital typesetting technology, specifically to a global collaborative layout generation system and method based on particle swarm optimization. It is applicable to scenarios that require controllable layout generation based on a template library and output of editable structured layout data, including but not limited to photo album / commemorative album typesetting, publication typesetting, advertising production and other fields. Background Technology
[0002] With the rapid development of digital media, automated layout generation technology has been widely used in various fields. Currently, layout generation technologies on the market are mainly divided into four categories: AI-based layout generation technology, rule-based layout generation technology, simple template matching-based layout generation technology, and machine learning-based layout generation technology.
[0003] AI-based layout generation technology uses deep learning models to directly generate layouts, offering high creativity, but it suffers from limitations such as being uncontrollable (like a black box), difficult to modify later, unable to guarantee brand consistency, and high model training costs and long cycles. Rule-based layout generation technology offers strong controllability but lacks flexibility, making it difficult to adapt to complex scenarios and resulting in low layout matching accuracy. Layout generation technology based on simple template matching employs a local optimum strategy, lacking global optimization capabilities and failing to meet the needs of large-scale layout generation. While machine learning-based layout generation technology has some adaptive capabilities, it requires a large amount of training data, has poor real-time performance, and lacks sufficient controllability and modifiability of the generated results.
[0004] Existing layout generation technologies urgently need to achieve controllable layout generation based on existing templates, improve layout matching, enhance modifiability, support large-scale generation, achieve adaptive optimization, reduce manual intervention, and ensure brand consistency. This invention is a solution proposed to address the above shortcomings. Summary of the Invention
[0005] The main objective of this invention is to provide a global cooperative layout generation system and method based on particle swarm optimization, specifically including: Achieve controllable layout generation based on existing templates, solving the problems of existing AI image generation technology being black box and uncontrollable, and difficult to modify subsequently; Improve layout matching to ensure optimal content and template compatibility; Enhance the modifiability of the layout to facilitate subsequent manual adjustments; Supports large-scale layout generation, improving generation efficiency; Achieve adaptive optimization to meet the layout generation needs of different scenarios and scales; Reduce human intervention and increase automation; Ensure brand consistency and adherence to design guidelines in the layout.
[0006] To achieve the above objectives, the present invention provides the following technical solution: A global cooperative layout generation system based on particle swarm optimization includes: The input module is configured to receive a multi-page content group and a target template identifier; The feature extraction module is configured to extract feature information for each content group, the feature information including at least image aspect ratio, image size features, and text length features; The scoring construction module is configured to obtain a set of candidate pages from the template library based on the target template identifier, and calculate a scoring matrix between the content group and the set of candidate pages based on the feature information. The global collaborative allocation module is configured to take the scoring matrix as input, perform a one-time global collaborative allocation of multi-page content groups based on the particle swarm optimization algorithm under page capacity constraints, and output the global optimal allocation result of each content group to the candidate page, wherein the page capacity constraint is limited by a preset configurable parameter to limit the maximum number of times each candidate page can be reused; The layout generation module is configured to perform element binding on the content group and generate multi-page structured layout data based on the global optimal allocation result. The structured layout data includes at least page information and page element information. The page element information includes at least element type, position size, layer level, data source and layout attributes. The output module is configured to output the structured layout data for rendering or secondary editing.
[0007] A global cooperative layout generation method based on particle swarm optimization includes the following steps: S1: Obtain a set of candidate pages from the template library based on the target template identifier, wherein each candidate page includes at least one page element, and the page element contains element type, position size and hierarchy information; S2: Receive multiple content groups and extract feature information for each content group. The feature information includes at least image aspect ratio, image size features, and text length features. S3: Calculate the scoring matrix between the multi-page content group and the candidate page set based on the feature information; S4: Using the scoring matrix as input, perform a one-time global collaborative allocation of multi-page content groups based on the particle swarm optimization algorithm under the page capacity constraint, and output the global optimal allocation result of each content group to the candidate page, wherein the page capacity constraint is limited by a preset configurable parameter to limit the maximum number of times each candidate page can be reused; S5: Based on the global optimal allocation result, bind the images and text in the content group to the image elements and text elements of the corresponding candidate pages respectively, and generate the bound page element information; S6: Perform rule-based layout adjustments on the bound page. The rule-based layout adjustments include at least: scaling images proportionally according to the longest side constraint, and adaptively adjusting the height of text boxes based on actual font measurements under width constraints. S7: Perform layer hierarchy constraints and overlap resolution on the page, and output structured layout data for multiple pages.
[0008] Furthermore, the global collaborative allocation module includes: Particle initialization unit: used to generate the initial page allocation scheme; Fitness evaluation unit: used to evaluate the fitness of the page allocation scheme, wherein the fitness includes at least the sum of the scores corresponding to the scoring matrix and the penalty item for violating the page capacity constraint; Particle Update Unit: Used to optimize page allocation schemes based on the speed and position update rules of the particle swarm optimization algorithm; Repair operator unit: Used to perform feasibility repair on the optimized page allocation scheme to ensure that page capacity constraints are met.
[0009] Furthermore, the layout generation module includes: Element replacement unit: Used to bind images and text in a content group to the corresponding image and text elements on the page; Element Adjustment Unit: Used to perform regular adjustments to the size, position, or layout attributes of bound image and text elements; Layout adjustment unit: Used to perform layer hierarchy constraints and overlap resolution to obtain the final page layout.
[0010] Furthermore, step S4 includes: S4.1: Calculate the score between the content group and the candidate page based on the feature information to form a score matrix. ; S4.2: Initialize the particle swarm, where the position vector of each particle is the candidate page index vector corresponding to each content group; S4.3: Perform a fitness evaluation on the particles, wherein the fitness includes at least the sum of the scores corresponding to the scoring matrix and a penalty term for violating the page capacity constraint; S4.4: Update particle velocity and particle position, and iteratively update individual optimal and global optimal; S4.5: When the termination condition is met, output the globally optimal page allocation result and perform a repair operator on the globally optimal page allocation result to satisfy the page capacity constraint.
[0011] Furthermore, step S5 includes: S5.1: Perform image binding on the image elements in the candidate page, establish a correspondence between the images in the content group and the image elements, prioritize matching based on element identifier and image identifier, and allocate in order if no match is found; S5.2: Perform text binding on the text elements in the candidate page, establish a correspondence between the text in the content group and the text elements, calculate the similarity based on the mapping match, fuzzy match or keyword match between the text description field and the text element name, and complete the binding when the similarity is not lower than the threshold; otherwise, allocate in order. S5.3: Write the corresponding data source fields for the bound image and text elements to form an editable element-level content reference relationship.
[0012] Furthermore, step S6 also includes: measuring the text size of the text element using actual font rendering, and performing line breaks and height expansion within the constraint of not exceeding the width of the template text box.
[0013] Furthermore, it also includes an intelligent cover recognition step, which sets the score of the content group containing the image and the corresponding cover or back cover page to a low value that cannot be selected, in order to avoid cover mismatch.
[0014] Furthermore, it also includes a dynamic parameter adjustment step, which automatically adjusts the particle swarm size, maximum number of iterations, and early stop patience value based on the number of content groups and candidate pages.
[0015] Furthermore, it also includes an adaptive scoring step: adjusting the score of candidate pages by adding or subtracting points based on historical matching data, wherein the historical matching data includes at least the page usage frequency, matching success rate, and average score.
[0016] This invention has the following significant advantages over the prior art: 1. High controllability: The layout is generated based on the template library, and the output is structured layout data that is predictable, constrainable, and editable, solving the black box problem of AI-generated images; 2. Excellent global collaboration: The allocation of multi-page content groups and candidate pages is treated as a global collaborative optimization problem, and the allocation is completed in one go, reducing inter-page conflicts and uneven allocation; 3. Excellent editability: Outputs element-level structured data, facilitating secondary editing of materials, adjustment of positions, and modification of styles; 4. High efficiency and scalability: Through global collaborative allocation and rule-based adjustment of appropriate groupings, batch generation can be achieved, and optimization parameters can be dynamically adjusted. 5. Strong robustness and stability: When global optimization or constraint repair fails, a degradation strategy is triggered to ensure stable system output; 6. Consistency and Standards Adherence: Based on the template structure, constrain layer hierarchy, element types, and page dimensions to maintain brand style and design standards; 7. Optional adaptive optimization: Based on historical matching data, an adaptive adjustment and polling mechanism for scores is implemented to improve the long-term stability and balance of allocation. Attached Figure Description
[0017] Figure 1 System overall architecture diagram; Figure 2 Flowchart of multi-page global collaborative allocation and layout generation; Figure 3 : Layout to generate data flow diagram; Figure 4 : Schematic diagram of particle swarm optimization algorithm. Detailed Implementation
[0018] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. The components of the embodiments of the present invention described and shown in the accompanying drawings can generally be arranged and designed in various different configurations.
[0019] This invention proposes a global cooperative layout generation system based on particle swarm optimization, comprising: The input module is configured to receive a multi-page content group and a target template identifier; The feature extraction module is configured to extract feature information for each content group, the feature information including at least image aspect ratio, image size features, and text length features; The scoring construction module is configured to obtain a set of candidate pages from the template library based on the target template identifier, and calculate a scoring matrix between the content group and the set of candidate pages based on the feature information. The global collaborative allocation module is configured to take the scoring matrix as input, perform a one-time global collaborative allocation of multi-page content groups based on the particle swarm optimization algorithm under page capacity constraints, and output the global optimal allocation result of each content group to the candidate page, wherein the page capacity constraint is limited by a preset configurable parameter to limit the maximum number of times each candidate page can be reused; The layout generation module is configured to perform element binding on the content group and generate multi-page structured layout data based on the global optimal allocation result. The structured layout data includes at least page information and page element information. The page element information includes at least element type, position size, layer level, data source and layout attributes. The output module is configured to output the structured layout data for rendering or secondary editing.
[0020] A global cooperative layout generation method based on particle swarm optimization includes the following steps: S1: Obtain a set of candidate pages from the template library based on the target template identifier, wherein each candidate page includes at least one page element, and the page element contains element type, position size and hierarchy information; S2: Receive multiple content groups and extract feature information for each content group. The feature information includes at least image aspect ratio, image size features, and text length features. S3: Calculate the scoring matrix between the multi-page content group and the candidate page set based on the feature information; S4: Using the scoring matrix as input, perform a one-time global collaborative allocation of multi-page content groups based on the particle swarm optimization algorithm under the page capacity constraint, and output the global optimal allocation result of each content group to the candidate page, wherein the page capacity constraint is limited by a preset configurable parameter to limit the maximum number of times each candidate page can be reused; S5: Based on the global optimal allocation result, bind the images and text in the content group to the image elements and text elements of the corresponding candidate pages respectively, and generate the bound page element information; S6: Perform rule-based layout adjustments on the bound page. The rule-based layout adjustments include at least: scaling images proportionally according to the longest side constraint, and adaptively adjusting the height of text boxes based on actual font measurements under width constraints. S7: Perform layer hierarchy constraints and overlap resolution on the page, and output structured layout data for multiple pages.
[0021] Furthermore, the global collaborative allocation module includes: Particle initialization unit: used to generate the initial page allocation scheme; Fitness evaluation unit: used to evaluate the fitness of the page allocation scheme, wherein the fitness includes at least the sum of the scores corresponding to the scoring matrix and the penalty item for violating the page capacity constraint; Particle Update Unit: Used to optimize page allocation schemes based on the speed and position update rules of the particle swarm optimization algorithm; Repair operator unit: Used to perform feasibility repair on the optimized page allocation scheme to ensure that page capacity constraints are met.
[0022] Furthermore, the layout generation module includes: Element replacement unit: Used to bind images and text in a content group to the corresponding image and text elements on the page; Element Adjustment Unit: Used to perform regular adjustments to the size, position, or layout attributes of bound image and text elements; Layout adjustment unit: Used to perform layer hierarchy constraints and overlap resolution to obtain the final page layout.
[0023] Furthermore, step S4 includes: S4.1: Calculate the score between the content group and the candidate page based on the feature information to form a score matrix. ; S4.2: Initialize the particle swarm, where the position vector of each particle is the candidate page index vector corresponding to each content group; S4.3: Perform a fitness evaluation on the particles, wherein the fitness includes at least the sum of the scores corresponding to the scoring matrix and a penalty term for violating the page capacity constraint; S4.4: Update particle velocity and particle position, and iteratively update individual optimal and global optimal; S4.5: When the termination condition is met, output the globally optimal page allocation result and perform a repair operator on the globally optimal page allocation result to satisfy the page capacity constraint.
[0024] Furthermore, step S5 includes: S5.1: Perform image binding on the image elements in the candidate page, establish a correspondence between the images in the content group and the image elements, prioritize matching based on element identifier and image identifier, and allocate in order if no match is found; S5.2: Perform text binding on the text elements in the candidate page, establish a correspondence between the text in the content group and the text elements, calculate the similarity based on the mapping match, fuzzy match or keyword match between the text description field and the text element name, and complete the binding when the similarity is not lower than the threshold; otherwise, allocate in order. S5.3: Write the corresponding data source fields for the bound image and text elements to form an editable element-level content reference relationship.
[0025] Furthermore, step S6 also includes: measuring the text size of the text element using actual font rendering, and performing line breaks and height expansion within the constraint of not exceeding the width of the template text box.
[0026] Furthermore, it also includes an intelligent cover recognition step, which sets the score of the content group containing the image and the corresponding cover or back cover page to a low value that cannot be selected, in order to avoid cover mismatch.
[0027] Furthermore, it also includes a dynamic parameter adjustment step, which automatically adjusts the particle swarm size, maximum number of iterations, and early stop patience value based on the number of content groups and candidate pages.
[0028] Furthermore, it also includes an adaptive scoring step: adjusting the score of candidate pages by adding or subtracting points based on historical matching data, wherein the historical matching data includes at least the page usage frequency, matching success rate, and average score.
[0029] Specifically, the core technical architecture of this invention includes the following key components: 1. Algorithm selection strategy The system performs global collaborative allocation of multi-page content groups at once. The allocation algorithm can be selected based on configuration parameters: when the number of content groups is large, the particle swarm optimization algorithm is used for global optimization first. If the solution fails or the repair fails, it will automatically degrade to the greedy allocation algorithm; when the number of content groups is 1, traversal scoring or greedy strategy can be used for fast allocation.
[0030] 2. Construction of the rating matrix and definition of rating items The candidate page set is extracted from the template library. Each candidate page includes page dimensions and an element list, and the number of image elements, text elements, and related size information are counted. A scoring matrix is also included. middle, Image matching rating With text carrying score We get the weighted result, i.e. , where wimg and wtext are configurable weight coefficients.
[0031] Image matching score is calculated based on the difference between the aspect ratio of the image and the aspect ratio of the position box of the image element on the candidate page, and the degree of matching between the image size and the position box size. It uses monotonic functions such as linear decay and S-curve to map the difference as the score. Text carrying capacity score is calculated based on the text length of the content group and the ideal length of the text element on the candidate page or the text box size. It uses an S-curve function on the length ratio to calculate a higher score when the text length is close to the carrying capacity. When the number of image elements on the candidate page is inconsistent with the number of images in the content group, Set to not select low values (such as negative infinity or a very small constant); optionally set cover / back cover suppression rules to set the corresponding scores of content groups containing images and cover / back cover pages to not select low values; also, score bias can be calculated based on historical allocation statistics to adaptively adjust the score matrix without changing the not selectable constraint.
[0032] 3. Greedy Algorithm Greedy algorithms are suitable for fast allocation of content groups with a small number of elements and for degradation schemes of particle swarm optimization; initialize the set of allocated content groups and page usage counts. All For rating Sort the candidate pairs in descending order and iterate through them one by one. If the content group is not allocated and the page is not over-capacity, perform the allocation until all content groups are allocated or there are no feasible candidate pairs.
[0033] 4. Global Cooperative Allocation Based on Particle Swarm Optimization Suitable for global collaborative allocation of multi-page content groups, pursuing the globally optimal solution, and adapted to large-scale batch generation scenarios; each particle is of length... integer vectors , Indicates the first The first particle Page indexes assigned to each content group; The fitness function is: in To constrain the penalties for violations; The speed update rules are as follows: in For inertial weights, As a learning factor, Let the random factor be in the interval (0,1). For particles The optimal position of an individual The optimal global position is determined by the following position update rule: The repair operator is used to ensure the feasibility of the solution and attempts a maximum of 10 repairs, including steps such as recounting page usage, sorting pages by overload level, prioritizing the repair of low-scoring groups, and finding the best alternative pages.
[0034] 5. Adjustment of standardized layout A tiered adjustment strategy is adopted, optimizing step by step from the micro to the macro level: Element replacement: Image matching supports exact ID matching, name inclusion matching, and sequential matching; text matching adopts a waterfall process, supports multiple matching methods, has a built-in common semantic mapping table, and supports custom extensions; Element fine-tuning: Images are scaled proportionally according to the longest side constraint, maintaining aspect ratio and template position; text boxes are based on actual font measurements, with width not exceeding template width, height increased as needed, and font rollback supported; Global layout optimization: The AABB collision detection algorithm is used to detect overlapping elements. Upper-level elements are moved downwards first, and lower-level elements are moved upwards if they are outside the canvas. Warnings are recorded when elements cannot be moved. This ensures that elements are within the canvas area and completes text rearrangement and overall coordination. Policy mode support: Built-in standard policies, new policies can be added through a registration mechanism, and policies can be selected based on configuration files.
[0035] 6. Adaptive scoring mechanism Historical data such as the frequency of use of candidate pages, matching success rate, and average score are collected. High-frequency pages and high success rate pages are given bonus points, low-scoring pages are deducted points, and recently unused pages are given bonus points to balance the frequency of use and achieve adaptive score adjustment.
[0036] 7. Dynamic parameter adjustment Based on the number of content groups m and the number of candidate pages n, the particle swarm size (range 20-50), the maximum number of iterations (range 300-800), and the early stopping patience value are automatically adjusted. For small-scale problems, a smaller particle swarm and fewer iterations are used to improve efficiency, while for large-scale problems, a larger particle swarm and more iterations are used to improve global search capabilities.
[0037] 8. Intelligent Cover Recognition The system identifies cover pages based on multiple rules, including page index keywords, image text quantity, and location information. It sets the corresponding score of content groups containing images and cover / back cover pages to a low value that cannot be selected, thus avoiding mismatches.
[0038] 9. Support infrastructure It includes a template management system that supports adding, deleting, modifying, and querying templates, as well as a rendering module that provides image rendering capabilities for template library maintenance and layout result verification.
[0039] 10. Template Format Requirements Supports single PSD files (suitable for single-page templates, covers, and back covers) and compressed file formats (suitable for multi-page templates). PSD templates should be organized according to a standard layer structure: background layer group [bg] or background (optional), image placeholders (image_placeholder_{number}), decoration layer group, and text layers (retaining complete style information). Recommended canvas size is 3600×2400 pixels @300dpi for double-page templates and 1800×2400 pixels @300dpi for single-page templates; custom resolutions are supported. Color mode is RGB 8-bit. Recommended Chinese fonts include SimHei, SimSun, and Microsoft YaHei; ensure that the fonts are commercially licensed. Specific implementation examples: I. System Composition As shown in Figure 1, the system of the present invention mainly consists of the following modules: Input module: Receives multi-page content groups (each page contains a set of images and a set of text) and template identification information, verifies data integrity and legality, and converts it into a structured format for output; Feature extraction module: Extracts image features (size, aspect ratio, quantity, etc.) and text features (length, description fields, etc.) page by page to form a batch feature set; The scoring construction module extracts a set of candidate pages from the template library and constructs a "content group - candidate page" scoring matrix based on the batch feature set and scoring strategy. Global Cooperative Allocation Module: Based on the particle swarm optimization algorithm, global cooperative allocation is performed under page capacity constraints. It includes particle initialization, fitness evaluation, particle update, repair operator and degradation unit. When repair fails, it falls back to greedy allocation. Layout generation module: Generates structured layout data based on the allocation results, including element replacement, element fine-tuning, layer constraints, and overlap resolution units; Output module: Outputs multi-page structured layout data (LayoutData) for rendering by the rendering module or secondary editing by the editor; Adaptive scoring module (optional): Based on historical matching data, adaptively adds or subtracts points and polls to adjust the scores of candidate pages, and outputs the adjusted scoring matrix or bias.
[0041] II. Implementation of Core Algorithm (I) Explanation of Symbols and Parameters Number of content groups; Number of candidate pages; : No. The content group was assigned to the first The rating of each candidate page; , The weighting coefficients of image rating items and text rating items; , Image matching score and text carrying score; , The aspect ratio of images in the content group versus the aspect ratio of the image position frame on the candidate page; , , , Image width and height versus the width and height of the position frame. , This refers to the scaling ratio; , The weighting coefficients for aspect ratio and size sub-items in image rating; , , : Smoothing / decay coefficient of the scoring function; The maximum score for the text item; , : Content group text length and candidate page text capacity; Maximum number of times page capacity constraints can be reused (in one embodiment) ); Candidate Page The number of times it has been used; Particle swarm optimization algorithm parameters (inertia weight, individual learning factor, social learning factor); Constraint penalty coefficient; : Fix the maximum number of attempts for the operator; Iteration rounds ( ).
[0042] (II) Implementation of Greedy Algorithm initialization: , ; Generate a set of all candidate pairs and sort them by Sort the candidate pairs in descending order, traverse them sequentially, and assign the candidate pairs that meet the condition of "content group not assigned and page not exceeding capacity constraint". Update the assigned set and page usage count until all content groups are assigned or there are no feasible candidate pairs. Output the feasible assignment results and scoring information.
[0043] (III) Implementation of Particle Swarm Optimization Algorithm Initialize the particle swarm, generating a page index vector of length m for each particle as its initial position and velocity; during the iteration process, calculate the particle fitness, update the individual optimum and global optimum, update the particle velocity and position according to the rules, and end the iteration when the termination condition is met (reaching the maximum number of iterations or stopping early); perform a repair operator on the global optimum result, and if the repair fails, trigger a degradation strategy, outputting the global collaborative allocation result and scoring information that meet the capacity constraints.
[0044] (iv) Implementation of fitness assessment Overall score Penalty items fitness When the repair operator guarantees that the capacity constraint is met, the total score can be directly used as the fitness.
[0045] (V) Particle Update Implementation Generate random factors Calculated according to the speed update formula Then, the amplitude is limited, and continuous positions are obtained according to the position update formula, mapped to discrete page indices, and then clipped to... Range, to obtain .
[0046] (vi) Repair operator implementation Repeated execution not exceeding Secondary fix: Count page usage and identify overloaded pages. For each overloaded page, select a migration group based on the assigned content group score from low to high. Among the candidate pages without capacity constraints, select the highest-scoring replacement page and update the assignment vector and usage count. If the system is still overloaded, the repair will fail and a downgrade will be triggered.
[0047] (vii) Implementation of the adaptive scoring mechanism Calculate the score bias for each candidate page. ,implement No bias is applied to unselectable rating items, and the adjusted rating matrix is output. .
[0048] III. Work Process Input phase: Receive multi-page content groups and template library information, verify data validity, and convert to a structured format; Feature extraction: Extract image and text features page by page to form a batch feature set; Global collaborative allocation: Extract a set of candidate pages from the template library, construct a scoring matrix, perform particle swarm optimization for global collaborative allocation, and if the fix fails, downgrade to greedy allocation and output page allocation metadata; Content conversion: Convert user content to standard format page by page; plain text pages or pages without images can directly enter layout generation. Layout Combination: Combine content groups and candidate pages on a page-by-page basis to generate preliminary structured layout data and bind text, images and template elements; Layout adjustments: Perform micro-adjustments (element size and position optimization) and macro-adjustments (overlap resolution, boundary constraints, and text rearrangement); Final output: Output multi-page structured layout data; Adaptive optimization (optional): Collect historical data, adjust the scoring strategy, and optimize the subsequent allocation effect.
[0049] IV. Application Examples Multi-page batch generation (taking album as an example): Construct multi-page content groups and candidate page sets in an offline environment, perform a one-time global collaborative allocation, and output the allocation results, matching scores and solution status of each page in JSON format for review and verification; Advertising production: Automatically generates poster and flyer layouts, strictly adhering to brand design specifications, with controllable and highly modifiable layout results.
[0050] V. Specific Embodiments (corresponding to steps S1-S7 of claim 2) Example Input: A multi-page content group of a photo album (each page contains a set of images and a set of text; images contain source information and identifiers, and text contains content and description fields); a target template (a multi-page template in the template library, containing a set of candidate pages, and each page contains a size and a list of elements).
[0051] S1 (Candidate Page Acquisition): Read the candidate page set of the target template from the template library, filter the cover and back cover pages, and obtain the set of pages participating in the matching. Each candidate page contains at least the number and position size information of image elements. S2 (Feature Extraction): Extract image features (width, height, aspect ratio) and text features (length, description field or type identifier) for each page's content group, and organize them into batch feature sets by page; for content groups without images, only extract text features, and select pages or merge and distribute results based on text carrying capacity; S3 (Scoring Matrix Construction): Calculates the matching score between content groups and candidate pages. ;in, , , ; When there are multiple text elements, summation or averaging is performed; the scoring matrix is constructed according to priority: first, non-optional rules are executed, then cover suppression rules are executed optionally, and finally, adaptive scoring bias is applied optionally. S4 (Global Cooperative Allocation): Establish a global optimization model, solve it based on particle swarm optimization, the maximum number of page reuses is configurable (3 in the example), the particle is encoded as a page index vector, the fitness function contains the sum of scores and constraint penalty terms, after termination, the repair operator is executed, if the repair fails, it is downgraded to greedy allocation; S5 (Element Replacement and Binding): Image elements are matched first by identifier, and if no match is found, they are filled sequentially; text elements are matched based on a two-stage matching of the description field, and if no match is found, they are filled sequentially; data source fields are written to bound elements to form element-level reference relationships; S6 (Regular Layout Adjustment): Images are scaled proportionally according to the longest side constraint; text boxes wrap and expand their height based on the actual font size; z-index ranges are forcibly set for different types of elements; overlapping text elements are detected and their positions are adjusted. S7 (Structured Output): Outputs LayoutData, which includes at least template identifiers, a list of pages (including page_index, page_size, and elements), and a list of elements (including element_type, position, style, source, and typography), supporting rendering and secondary editing.
[0052] VI. Example of Output Data Structure The structured layout data is represented in a hierarchical manner, including template_id (template identifier), layout_info (page list, each page contains page_index, page_size and elements), elements (elements list, each element contains element_type, position (x, y, width, height), style (z_index, etc.), source (data source), and typography (text element specific, including font, font size, etc.), which facilitates subsequent element-level editing.
[0053] The present invention and its embodiments have been described above. This description is not restrictive, and the accompanying drawings are only one embodiment of the present invention; the actual structure is not limited thereto. In conclusion, if those skilled in the art are inspired by this description and design similar structures and embodiments without departing from the spirit of the invention, such designs should fall within the protection scope of the present invention.
Claims
1. A global cooperative layout generation system based on particle swarm optimization, characterized in that, include: The input module is configured to receive a multi-page content group and a target template identifier; The feature extraction module is configured to extract feature information for each content group, the feature information including at least image aspect ratio, image size features, and text length features; The scoring construction module is configured to obtain a set of candidate pages from the template library based on the target template identifier, and calculate a scoring matrix between the content group and the set of candidate pages based on the feature information. The global collaborative allocation module is configured to take the scoring matrix as input, perform a one-time global collaborative allocation of multi-page content groups based on the particle swarm optimization algorithm under page capacity constraints, and output the global optimal allocation result of each content group to the candidate page, wherein the page capacity constraint is limited by a preset configurable parameter to limit the maximum number of times each candidate page can be reused; The layout generation module is configured to perform element binding on the content group and generate multi-page structured layout data based on the global optimal allocation result. The structured layout data includes at least page information and page element information. The page element information includes at least element type, position size, layer level, data source and layout attributes. The output module is configured to output the structured layout data for rendering or secondary editing.
2. A global cooperative layout generation method based on particle swarm optimization, characterized in that, Includes the following steps: S1: Obtain a set of candidate pages from the template library based on the target template identifier, wherein each candidate page includes at least one page element, and the page element contains element type, position size and hierarchy information; S2: Receive multiple content groups and extract feature information for each content group. The feature information includes at least the image aspect ratio, image size features, and text length features. S3: Calculate the scoring matrix between the multi-page content group and the candidate page set based on the feature information; S4: Using the scoring matrix as input, perform a one-time global collaborative allocation of multi-page content groups based on the particle swarm optimization algorithm under the page capacity constraint, and output the global optimal allocation result of each content group to the candidate page, wherein the page capacity constraint is limited by a preset configurable parameter to limit the maximum number of times each candidate page can be reused; S5: Based on the global optimal allocation result, bind the images and text in the content group to the image elements and text elements of the corresponding candidate pages respectively, and generate the bound page element information; S6: Perform rule-based layout adjustments on the bound page. The rule-based layout adjustments include at least: scaling images proportionally according to the longest side constraint, and adaptively adjusting the height of text boxes based on actual font measurements under width constraints. S7: Perform layer hierarchy constraints and overlap resolution on the page, and output structured layout data for multiple pages.
3. The global cooperative layout generation system based on particle swarm optimization according to claim 1, characterized in that, The global collaborative allocation module includes: Particle initialization unit: used to generate the initial page allocation scheme; Fitness evaluation unit: used to evaluate the fitness of the page allocation scheme, wherein the fitness includes at least the sum of the scores corresponding to the scoring matrix and the penalty item for violating the page capacity constraint; Particle Update Unit: Used to optimize page allocation schemes based on the speed and position update rules of the particle swarm optimization algorithm; Repair operator unit: Used to perform feasibility repair on the optimized page allocation scheme to ensure that page capacity constraints are met.
4. The global cooperative layout generation system based on particle swarm optimization according to claim 1, characterized in that, The layout generation module includes: Element replacement unit: Used to bind images and text in a content group to the corresponding image and text elements on the page; Element Adjustment Unit: Used to perform regular adjustments to the size, position, or layout attributes of bound image and text elements; Layout adjustment unit: Used to perform layer hierarchy constraints and overlap resolution to obtain the final page layout.
5. The global cooperative layout generation method based on particle swarm optimization according to claim 2, characterized in that, Step S4 includes: S4.1: Calculate the score between the content group and the candidate page based on the feature information to form a score matrix. ; S4.2: Initialize the particle swarm, where the position vector of each particle is the candidate page index vector corresponding to each content group; S4.3: Perform a fitness evaluation on the particles, wherein the fitness includes at least the sum of the scores corresponding to the scoring matrix and a penalty term for violating the page capacity constraint; S4.4: Update particle velocity and particle position, and iteratively update individual optimal and global optimal; S4.5: When the termination condition is met, output the globally optimal page allocation result and perform a repair operator on the globally optimal page allocation result to satisfy the page capacity constraint.
6. The global cooperative layout generation method based on particle swarm optimization according to claim 2, characterized in that, Step S5 includes: S5.1: Perform image binding on the image elements in the candidate page, establish a correspondence between the images in the content group and the image elements, prioritize matching based on element identifier and image identifier, and allocate in order if no match is found; S5.2: Perform text binding on the text elements in the candidate page, establish a correspondence between the text in the content group and the text elements, calculate the similarity based on the mapping match, fuzzy match or keyword match between the text description field and the text element name, and complete the binding when the similarity is not lower than the threshold; otherwise, allocate in order. S5.3: Write the corresponding data source fields for the bound image and text elements to form an editable element-level content reference relationship.
7. The global cooperative layout generation method based on particle swarm optimization according to claim 2, characterized in that, Step S6 further includes: measuring the text size of the text element using actual font rendering, and performing line breaks and height expansion within the constraint of not exceeding the width of the template text box.
8. The global cooperative layout generation method based on particle swarm optimization according to claim 2, characterized in that, It also includes an intelligent cover recognition step, which sets the score of the content group containing the image to the corresponding cover or back cover page to a low value that cannot be selected, in order to avoid cover mismatch.
9. The global cooperative layout generation method based on particle swarm optimization according to claim 2, characterized in that, It also includes a dynamic parameter adjustment step, which automatically adjusts the particle swarm size, maximum number of iterations, and early stop patience value based on the number of content groups and candidate pages.
10. The global cooperative layout generation method based on particle swarm optimization according to claim 2, characterized in that, It also includes an adaptive scoring step: adjusting the scores of candidate pages by adding or subtracting points based on historical matching data, which includes at least page usage frequency, matching success rate, and average score.