Webpage segmentation adaptation method, system and device and medium

By introducing a comprehensive web page segmentation adaptive fine-tuning module and post-processing technology into the general visual segmentation model, the problem of bounding box inaccuracy and overlap in complex web page segmentation is solved, and more efficient and accurate web page segmentation is achieved to meet the needs of the modern Web environment. Information retrieval needs.

CN118606583APending Publication Date: 2024-09-06CHINA PACIFIC INSURANCE (GRP) CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410636354.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-05-22
Publication Date
2024-09-06

AI Technical Summary

Technical Problem

Existing web page segmentation technologies have bounding box inaccuracies and overlapping problems when processing complex web pages, and are difficult to meet the needs of efficient and accurate information retrieval in modern Web environments.

Method used

Adopt a pre-trained general visual segmentation model, and introduce a comprehensive web page segmentation adaptive fine-tuning module in its image encoder part, including image block fine-tuning, structural feature fine-tuning and adapter modules, combined with post-processing technologies such as spatial context collaborative segmentation fusion and OCR Driven text boundary refinement to optimize segmentation results.

Benefits of technology

It improves the accuracy and efficiency of web page segmentation, enhances the model's ability to represent specific web page areas, ensures the accuracy and coverage of segmentation frames, and is suitable for high-quality information retrieval and content analysis.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118606583A
    Figure CN118606583A
Patent Text Reader

Abstract

The invention provides a webpage segmentation adaptation method and system. The method comprises the following steps: providing a pre-trained universal visual segmentation model; providing a comprehensive webpage segmentation adaptability fine tuning module at an image encoder part of the pre-trained universal visual segmentation model; performing fine training on the pre-trained universal visual segmentation model by using the comprehensive webpage segmentation adaptability fine tuning module, and performing structure fine tuning on a mask decoder part of the pre-trained universal visual segmentation model to obtain a fine universal visual segmentation model; and post-processing a visual segmentation result output by the refined universal visual segmentation model, combining overlapped segmentation frames, refining and correcting the positions of the segmentation frames, and obtaining a final segmentation result. According to the method, the limitation of a general visual segmentation model in the webpage segmentation field is effectively solved, the processing efficiency and the result accuracy are improved, and the method is suitable for being applied to scenes such as information retrieval.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of web page information technology retrieval technology, and in particular to an efficient web page segmentation and adaptation method, system, device and medium. Background Art

[0002] With the rapid development of the Internet, the Web has become the world's largest information library. In this information-rich environment, web pages, as the basic unit of the Web, often integrate multiple topics and independent content blocks. In order to more deeply understand and efficiently use these contents, web page segmentation technology came into being.

[0003] Web pages are mainly built based on HTML (HyperText Markup Language). As the standard markup language for creating web pages, HTML enables browsers to interpret and render them into visual web page content. HTML documents are composed of multiple nested elements, which together form a document tree structure called DOM (Document Object Model). In this structure, each node corresponds to an HTML tag. These tags and their key components such as attributes, character data types, character references, and entity references enable web designers to embed images and objects in web pages, create interactive forms, and represent various semantic information in a structured manner.

[0004] The core goal of web page segmentation is to divide web page content into different semantic or functional blocks according to human visual perception. As a key technology in the intersection of computer vision and information retrieval, web page segmentation performs detailed division of the semantic content and visual structure of web pages. At present, a web page usually contains multiple functional areas and information blocks, such as the main text area, navigation, sidebar, header, footer and advertising column. The information in these blocks is rich and diverse, and each has a unique semantic meaning. Therefore, accurately segmenting web pages according to their structure and semantic content is crucial for applications such as information retrieval, content extraction and web page adaptation.

[0005] Traditional information retrieval systems often treat the entire web page as a basic information unit, extracting keywords and building indexes on it. However, with the advancement of Web front-end technology, the content and structure of web pages have become increasingly complex. This complexity makes it difficult for traditional methods to handle modern web pages. Therefore, web page segmentation technology, as a method that can divide a web page into multiple semantically related content segments, provides new possibilities for improving the accuracy and efficiency of information retrieval systems.

[0006] The web page segmentation problem has been explored from many perspectives. Some studies focus on solving the problem by analyzing the document structure of HTML pages, while others try to segment web pages from a visual perspective based on the document structure and the browser's rendering of the web page. However, due to the huge number of possible document structure layout patterns, this may lead to errors when migrating from training data to actual web data. In addition, some researchers try to segment web pages based on the actual retrieval elements of web documents - text, or purely visual methods that rely on web page screenshots.

[0007] Although the method based on the document object model tree can provide structured information, it may not accurately capture the user's visual perception. The segmentation method that combines vision and document structure tree and the text-based method also need to rely on the source code information of the web page. Purely visual methods may be affected by complex web page design, resulting in poor segmentation results.

[0008] The Segment Anything Model is a basic image segmentation model released by MetaAI in April 2023. It can support zero-sample migration, which is a major breakthrough in the field of computer vision and achieves the unification of image segmentation. The current model is trained on the SA-1B (Segment Anything 1-Billion) dataset, which contains more than 1.1 billion segmentation masks with high quality and diversity.

[0009] The general visual segmentation model has demonstrated its strong adaptability in the field of natural images. However, in the web page segmentation task, in order to maximize the detection of potential areas, the detection confidence threshold is usually set low, which ensures that the model captures as much relevant information as possible. Nevertheless, this approach also leads to certain problems, such as the inaccuracy of overlapping boxes and bounding boxes. Therefore, how to deal with inaccurate bounding boxes under complex conditions to obtain more accurate web page segmentation results has become the focus of current research. At present, no description or report of similar technology to the present invention has been found, and similar information at home and abroad has not yet been collected. Summary of the invention

[0010] In view of the above-mentioned deficiencies in the prior art, the present invention provides an efficient web page segmentation and adaptation method, system, terminal and medium.

[0011] According to a first aspect of the present invention, a web page segmentation and adaptation method is provided, comprising:

[0012] Provide a pre-trained general visual segmentation model;

[0013] In the image encoder part of the pre-trained general visual segmentation model, a comprehensive web page segmentation adaptive fine-tuning module is provided;

[0014] Using the comprehensive webpage segmentation adaptive fine-tuning module, the pre-trained general visual segmentation model is refined and trained, and the mask decoder part of the pre-trained general visual segmentation model is structurally fine-tuned to obtain a refined general visual segmentation model;

[0015] The visual segmentation result output by the refined general visual segmentation model is post-processed to merge overlapping segmentation frames and refine and correct the position of the segmentation frames to obtain a final segmentation result.

[0016] Preferably, providing a pre-trained general visual segmentation model comprises:

[0017] A general visual segmentation model is provided, and a parameter file of the general visual segmentation model is trained using a public training data set to obtain a pre-trained general visual segmentation model.

[0018] Preferably, in the image encoder part of the pre-trained general visual segmentation model, a comprehensive web page segmentation adaptive fine-tuning module is provided, comprising:

[0019] A comprehensive web page segmentation adaptive fine-tuning module is introduced into the image encoder part of the general visual segmentation model, and the module includes: an image block fine-tuning module, a structural feature fine-tuning module and an adapter module; wherein:

[0020] The image block fine-tuning module projects the original image embedding from a high-dimensional space into a reduced-dimensional feature space through an adjustable linear layer, so as to optimize the alignment between the pre-trained model and the target dataset;

[0021] The structural feature fine-tuning module pre-processes the input web page image and converts it into a grayscale image, calculates the gradient amplitude using the Sobel operator to identify the edge and structural features in the web page image; segments the obtained edge and structural features into non-overlapping image blocks consistent with the general visual segmentation model, and projects these image blocks into a feature space with reduced dimensionality using an adjustable linear layer to optimize the structural representation of the web page image;

[0022] The adapter module combines the outputs of the image segmentation fine-tuning module and the structural feature fine-tuning module, and uses a lightweight multi-layer perceptron to perform feature enhancement for a specific web page domain.

[0023] Preferably, the integrated webpage segmentation adaptive fine-tuning module is used to perform fine-tuning on the pre-trained general visual segmentation model, and to perform structural fine-tuning on the mask decoder part of the pre-trained general visual segmentation model, including:

[0024] Freezing some parameters of the image encoder of the pre-trained general visual segmentation model, and training the pre-trained general visual segmentation model using only the parameters in the comprehensive web page segmentation adaptive fine-tuning module;

[0025] The structure of the mask decoder part of the pre-trained general visual segmentation model is fine-tuned to adapt the image embedding vector obtained from the image encoder part.

[0026] Preferably, the post-processing of the visual segmentation result output by the refined general visual segmentation model, merging overlapping segmentation frames and refining and correcting the position of the segmentation frames comprises:

[0027] A post-processing module is introduced at the output end of the refined general visual segmentation model, and the post-processing module includes: a spatial context collaborative segmentation fusion module and an OCR-driven text boundary refinement module, wherein the spatial context collaborative segmentation fusion module is used to merge the overlapping segmentation boxes in the visual segmentation results output by the refined general visual segmentation model; the OCR-driven text boundary refinement module uses the text data extracted from the OCR technology to refine and correct the position of the segmentation box.

[0028] Preferably, the spatial context collaborative segmentation fusion module is used to merge overlapping segmentation frames in the visual segmentation results output by the refined general visual segmentation model, including:

[0029] Perform spatial analysis on the obtained bounding boxes to calculate the position, size and overlapping area of ​​each bounding box;

[0030] According to the spatial analysis results, the overlapping or adjacent bounding boxes are merged into a single bounding box, completing the merging of the overlapping segmentation boxes in the visual segmentation results.

[0031] Preferably, the OCR-driven text boundary refinement module uses text data extracted from the OCR technology to refine and correct the position of the segmentation box, including:

[0032] Use OCR technology to identify text data in web page images and obtain corresponding text boxes;

[0033] Performing cluster analysis on the text frame using the DBSCAN algorithm to identify the regional distribution of the text data;

[0034] According to the clustering of the text boxes and the distribution results of the text data, the position and size of the segmentation box are adjusted to ensure that the segmentation box can accurately cover the relevant text data area.

[0035] According to a second aspect of the present invention, there is provided a web page segmentation and adaptation system, comprising:

[0036] A segmentation model module, which is used to provide a pre-trained general visual segmentation model;

[0037] A comprehensive fine-tuning module, the module is used to introduce a comprehensive web page segmentation adaptive fine-tuning module into the image encoder part of the pre-trained general visual segmentation model;

[0038] A refinement training module, which utilizes the comprehensive webpage segmentation adaptive fine-tuning module to perform refinement training on the pre-trained general visual segmentation model, and performs structural fine-tuning on the mask decoder part of the pre-trained general visual segmentation model to obtain a refined general visual segmentation model;

[0039] A post-processing module is used to post-process the visual segmentation result output by the refined general visual segmentation model, merge overlapping segmentation frames, and refine and correct the position of the segmentation frames to obtain the final segmentation result.

[0040] According to a third aspect of the present invention, there is provided a web page segmentation and adaptation device, comprising at least one processor, at least one memory, and a computer program stored in the memory and executable on the processor, wherein the processor, when executing the computer program, can be used to execute any one of the methods described above in the present invention, or to run the system described above in the present invention.

[0041] According to a third aspect of the present invention, there is provided a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, can be used to execute any of the methods described above in the present invention, or to run the system described above in the present invention.

[0042] Due to the adoption of the above technical solution, the present invention has at least one of the following beneficial effects compared with the prior art:

[0043] The web page segmentation adaptation method, system, device and medium provided by the present invention, based on a general visual segmentation model, not only have good accuracy but also improve the transferability through training on a web page segmentation data set.

[0044] The web page segmentation adaptation method, system, device and medium provided by the present invention introduce key post-processing technologies to optimize the preliminary segmentation results. The post-processing technologies include visual segmentation result collaborative fusion technology and text information driven boundary optimization technology. Visual segmentation result collaborative fusion technology reduces duplication and improves the overall accuracy of the results by merging those overlapping or adjacent boundary boxes. Text information driven boundary optimization technology uses text data extracted by OCR technology to refine and correct the position of the segmentation boxes to ensure that they can more accurately cover the relevant text area.

[0045] The web page segmentation adaptation method, system, device and medium provided by the present invention, through the application of post-processing technology, not only improves the accuracy of segmentation, but also enhances the practicality and efficiency of the general visual segmentation model in a complex web page environment, making it more suitable for high-quality information retrieval and content analysis. This improvement enables the present invention to have significant advantages in providing accurate web page segmentation, and meets the needs of efficient and accurate processing in the modern Web environment. The efficient web page segmentation adaptation method adopted by the present invention can effectively obtain representations for specific web page fields by introducing comprehensive web page segmentation adaptive fine-tuning technology. This technology not only improves the model's understanding and processing capabilities of web page content, but also greatly improves the accuracy and practicality of web page segmentation through the refined processing of post-processing technology.

[0046] The web page segmentation adaptation method, system, device and medium provided by the present invention effectively overcome the limitations of the general visual segmentation model in the field of web page segmentation by introducing the comprehensive web page segmentation adaptive fine-tuning technology. The technology combines image block fine-tuning, structural feature fine-tuning and adapter technology, which not only enhances the generalization ability of the model by fine-tuning the alignment between the pre-training and target data sets, but also enriches the representation ability of the model by identifying and utilizing the structural features of the web page. In addition, the adapter technology fuses the outputs of the first two parts through a lightweight multi-layer perceptron, resulting in a representation enhancement for a specific web page field, effectively improving the model's depth of understanding of web page content, thereby obtaining more accurate web page segmentation.

[0047] The web page segmentation adaptation method, system, device and medium provided by the present invention further enhance the practicality and accuracy of the training model output by introducing post-processing technology. After the model training is completed, the spatial context collaborative segmentation fusion technology and the OCR-driven text boundary refinement technology can more accurately merge overlapping segmentation boxes and adjust the position of the boundary box according to the text data. These post-processing steps not only improve the accuracy of the segmentation results, but also enhance the effectiveness of the model in actual application scenarios, making the retrieval and analysis of web page content more accurate and efficient. BRIEF DESCRIPTION OF THE DRAWINGS

[0048] Other features, objects and advantages of the present invention will become more apparent from the detailed description of non-limiting embodiments made with reference to the following drawings:

[0049] Figure 1 The figure is a workflow diagram of a web page segmentation and adaptation method in a preferred embodiment of the present invention.

[0050] Figure 2 Schematic diagram of the working model of the web page segmentation and adaptation method in a preferred embodiment of the present invention.

[0051] Figure 3 (a) to (d) are schematic diagrams showing the operation of the adaptive fine-tuning module for integrated web page segmentation in a preferred embodiment of the present invention.

[0052] Figure 4 It is a schematic diagram of the operation of the spatial context collaborative segmentation and fusion module in a preferred embodiment of the present invention.

[0053] Figure 5 The figure is a working diagram of an OCR-driven text boundary refinement module in a preferred embodiment of the present invention.

[0054] Figure 6 Schematic diagram of component modules of a web page segmentation and adaptation system in a preferred embodiment of the present invention. DETAILED DESCRIPTION

[0055] The following is a detailed description of the embodiments of the present invention: This embodiment is implemented on the premise of the technical solution of the present invention, and a detailed implementation method and a specific operation process are given. It should be pointed out that for ordinary technicians in this field, several variations and improvements can be made without departing from the concept of the present invention, which all belong to the protection scope of the present invention.

[0056] An embodiment of the present invention provides an efficient web page segmentation adaptation method, which aims to improve the accuracy and efficiency of web page image segmentation. Based on a pre-trained general visual segmentation model, a comprehensive web page segmentation adaptive fine-tuning module is introduced to improve the model's representation ability and generalization performance for specific web pages through fine-tuning and fusion; a post-processing module is introduced to further process the model output results, and overlapping segmentation boxes are merged through the collaborative fusion technology of visual segmentation results to improve the overall accuracy of the results. At the same time, text information is used to drive boundary optimization technology to refine and correct the position of the segmentation box based on text data extracted by OCR; through the combined use of the above technologies, the method effectively solves the limitations of the general visual segmentation model in the field of web page segmentation, improves processing efficiency and result accuracy, and is suitable for application in scenarios such as information retrieval.

[0057] Specifically, Figure 1As shown, the webpage segmentation and adaptation method provided in this embodiment may include the following operations:

[0058] S1, provides a pre-trained general visual segmentation model;

[0059] S2, providing a comprehensive web page segmentation adaptive fine-tuning module based on the image encoder part of the pre-trained general visual segmentation model;

[0060] S3, using the comprehensive web page segmentation adaptive fine-tuning module to perform fine-tuning on the pre-trained general visual segmentation model, and perform structural fine-tuning on the mask decoder part of the pre-trained general visual segmentation model to obtain a refined general visual segmentation model;

[0061] S4, post-processing the visual segmentation results, merging overlapping segmentation frames, and refining and correcting the segmentation frame positions to obtain the final segmentation results.

[0062] In some preferred embodiments, the above S1, providing a pre-trained general visual segmentation model, may further include the following operations:

[0063] A general visual segmentation model is provided, and a parameter file of the general visual segmentation model is trained using a public training data set to obtain a pre-trained general visual segmentation model.

[0064] In a preferred embodiment of S1, a general visual segmentation model is obtained, and a model parameter file is trained using a public training data set to obtain a pre-trained general visual segmentation model; the pre-trained general visual segmentation model can also directly adopt an existing model. In this step, a web page segmentation data set can also be obtained at the same time and the web page images therein are pre-processed for use in fine-tuning the pre-trained general visual segmentation model; wherein the general visual segmentation model includes two parts: an image encoder and a mask decoder.

[0065] In some preferred embodiments, the above S2, in which a comprehensive web page segmentation adaptive fine-tuning module is provided in the image encoder part of the pre-trained general visual segmentation model, may further include the following operations:

[0066] A comprehensive webpage segmentation adaptive fine-tuning module is introduced into the image encoder part of the general visual segmentation model, and the module includes: an image block fine-tuning module, a structural feature fine-tuning module and an adapter module; wherein:

[0067] The image patch fine-tuning module projects the original image embedding (patch embedding) from a high-dimensional space into a reduced-dimensional feature space through an adjustable linear layer to optimize the alignment between the pre-trained model and the target dataset;

[0068] The structural feature fine-tuning module preprocesses the input web page image and converts it into a grayscale image, calculates the gradient amplitude using the Sobel operator to identify the edge and structural features in the web page image; segments the obtained edge and structural features into non-overlapping image blocks consistent with the general visual segmentation model, and uses an adjustable linear layer to project these image blocks into a reduced-dimensional feature space to optimize the structural representation of the web page image;

[0069] The adapter module combines the outputs of the image block fine-tuning module and the structural feature fine-tuning module, and uses a lightweight multi-layer perceptron to perform feature enhancement for specific web page domains.

[0070] In a preferred embodiment of S2, the image encoder part of the pre-trained general visual segmentation model is improved, and a comprehensive web page segmentation adaptive fine-tuning module is introduced. The module comprehensively includes: an image block fine-tuning module, a structural feature fine-tuning module and an adapter module, aiming to improve the model's representation ability and generalization performance for specific web pages through fine-tuning and fusion.

[0071] In some preferred implementations, in the above S3, the comprehensive webpage segmentation adaptive fine-tuning module is used to perform fine-tuning on the pre-trained general visual segmentation model, and the mask decoder part of the pre-trained general visual segmentation model is structurally fine-tuned, and the following operations may be further included:

[0072] Freeze some parameters of the image encoder of the pre-trained general visual segmentation model, and train the pre-trained general visual segmentation model only using the parameters in the comprehensive web page segmentation adaptive fine-tuning module;

[0073] Fine-tune the structure of the mask decoder part of a pre-trained general visual segmentation model to adapt the image embedding vector obtained from the image encoder part.

[0074] In a preferred embodiment of S3, during the model refinement training stage, the integrated web page segmentation adaptive fine-tuning module is used to fine-tune the model, including freezing the original image encoder parameters and fine-tuning the mask decoder structure to optimize the model performance.

[0075] In some preferred implementations, the above S4, post-processing the visual segmentation results, merging overlapping segmentation frames, and refining and correcting the positions of the segmentation frames, may further include the following operations:

[0076] A post-processing module is introduced at the output end of the refined general visual segmentation model, and the post-processing module includes: a spatial context collaborative segmentation fusion module and an OCR-driven text boundary refinement module, wherein the spatial context collaborative segmentation fusion module is used to merge the overlapping segmentation boxes in the visual segmentation results output by the refined general visual segmentation model; the OCR-driven text boundary refinement module uses the text data extracted from the OCR technology to refine and correct the position of the segmentation box.

[0077] In a preferred embodiment of S4, a post-processing module is introduced, which does not participate in the model training process and is specifically used to further process the output obtained from the trained model to improve the accuracy and practicality of the segmentation results.

[0078] In some preferred implementations, S41, a spatial context collaborative segmentation fusion module, is used to merge overlapping segmentation boxes in the visual segmentation results output by the refined general visual segmentation model, and may further include the following operations:

[0079] Perform spatial analysis on the obtained bounding boxes to calculate the position, size and overlapping area of ​​each bounding box;

[0080] According to the spatial analysis results, the overlapping or adjacent bounding boxes are merged into a single bounding box, completing the merging of the overlapping segmentation boxes in the visual segmentation results.

[0081] In a preferred embodiment of S41, a spatial context collaborative segmentation fusion module is introduced to specifically handle the collaborative fusion of visual segmentation results, thereby improving the overall accuracy of the results by merging overlapping segmentation boxes.

[0082] In some preferred embodiments, S42, the OCR-driven text boundary refinement module, using the text data extracted from the OCR technology to refine and correct the position of the segmentation box, may further include the following operations:

[0083] Use OCR technology to identify text data in web page images and obtain corresponding text boxes;

[0084] Use DBSCAN algorithm to cluster text boxes and identify the regional distribution of text data;

[0085] According to the clustering results of the text boxes and the distribution results of the text data, the position and size of the segmentation box are adjusted to ensure that the segmentation box can accurately cover the relevant text data area.

[0086] In a preferred embodiment of S42, an OCR-driven text boundary refinement module is introduced to refine and correct the position of the segmentation box using text data extracted from the OCR technology, thereby improving the accuracy and usability of the overall segmentation result.

[0087] The technical solution provided by the above embodiment of the present invention is further described in detail below in conjunction with a preferred embodiment and the accompanying drawings.

[0088] like Figure 1 and Figure 2 As shown, in this preferred embodiment, the web page segmentation and adaptation method includes:

[0089] S1, obtain a general visual segmentation model and its pre-trained model parameter file; at the same time, obtain a web page segmentation dataset and pre-process the web page images therein for use in fine-tuning the pre-trained general visual segmentation model; the general visual segmentation model includes two parts: an image encoder and a mask decoder.

[0090] S2 improves the image encoder part of the general visual segmentation model and introduces a comprehensive web page segmentation adaptive fine-tuning module, which comprehensively includes: image block fine-tuning module, structural feature fine-tuning module and adapter module, aiming to improve the model's representation ability and generalization performance for specific web pages through fine-tuning and fusion.

[0091] S3 uses the comprehensive web segmentation adaptive fine-tuning module to fine-tune the model training, including: freezing the original image encoder parameters and fine-tuning the mask decoder structure to optimize model performance.

[0092] S4, introduces a post-processing module, which does not participate in the model training process, and is specifically used to further process the output (i.e., visual segmentation result) obtained from the trained model to improve the accuracy and practicality of the segmentation result. Among them:

[0093] S41 introduces a spatial context collaborative segmentation fusion module, which specifically handles the collaborative fusion of visual segmentation results and improves the overall accuracy of the results by merging overlapping segmentation boxes.

[0094] S42, introduces an OCR-driven text boundary refinement module, which uses text data extracted from OCR technology to refine and correct the position of the segmentation box, thereby improving the accuracy and usability of the overall segmentation results.

[0095] In a further preferred embodiment, the above S1 includes: using a general visual segmentation model with high-resolution input (1024×1024 pixels) as the basic architecture. The pre-trained model parameters are obtained by training with a public data set to ensure that the model has good basic performance for general visual tasks. At the same time, for the images in the web page segmentation data set, standardization processing is performed, such as adjusting brightness, contrast, and normalizing image size to ensure the consistency of input data and the adaptability of the model.

[0096] In a further preferred embodiment, Figure 3 As shown in (a), the above S2, the comprehensive web page segmentation adaptive fine-tuning module, specifically includes:

[0097] S21, the image segmentation fine-tuning module, projects the original image embedding from a high-dimensional space into a reduced-dimensional feature space by designing an adjustable linear layer, thereby optimizing the alignment between the pre-trained model and the target dataset. This module controls the number of learning parameters by adjusting the scaling factor σ to achieve fine-tuning of image segmentation features to enhance the model's ability to understand the semantics of web page images and provide adaptability for the processing of subsequent modules.

[0098] S22, structural feature fine-tuning module, preprocesses the input web page image and converts it into a grayscale image, and uses the Sobel operator to calculate the gradient amplitude to identify the edge and structural features in the web page. This module further segments the calculated Sobel features into non-overlapping image blocks consistent with the general visual segmentation model, and uses an adjustable linear layer to project these image blocks into a reduced dimensional feature space to optimize the structural representation of the image.

[0099] S23, the adapter module, combines the outputs of the image block fine-tuning module and the structural feature fine-tuning module, and uses a lightweight multi-layer perceptron to achieve feature enhancement for specific web page domains. This module tailors the feature space for web page segmentation tasks by adjusting the model output to better adapt to the complexity of web page structure, improving the model's understanding and adaptability to web page structure.

[0100] In a preferred embodiment of S21, if Figure 3 As shown in (b), the goal of the image block fine-tuning module is to optimize the alignment between the pre-trained model and the target dataset. You can refer to the following operations:

[0101] S211, design an adjustable linear layer L1, which embeds the original image into I p Project from an original dimensional space M into a feature space f1 with reduced dimension m:

[0102] f1=L1(I p ),

[0103] M is the original embedding dimension (usually 768 dimensions), m is the dimension after dimensionality reduction by the linear layer, and σ is the scaling factor, which is equal to M divided by m, and is used to adjust the number of learning parameters and optimize the alignment between the model and the dataset.

[0104] S212, controlling the number of learning parameters by adjusting the scaling factor σ. In a preferred embodiment, σ is set to 4, aiming to balance model complexity and performance and enhance the model's ability to understand the semantics of web page images.

[0105] In a preferred embodiment of S22, Figure 3 As can be seen in (c), in order to capture the structural features of a web page, the following operations can be referred to:

[0106] S221, preprocess the input web page image and convert it into a grayscale image I g , the gradient magnitude is calculated using the Sobel operator.

[0107] S222, segment the calculated Sobel features into non-overlapping image blocks consistent with the general visual segmentation model, and project these image blocks into the reduced dimensional feature space f2 using a linear layer L2. x and S y The Sobel kernel in the x and y directions is shown in Figure 2. * represents the convolution operation, and P represents the step of splitting the features into non-overlapping image blocks.

[0108]

[0109] In a preferred embodiment of S23, the adapter module fuses the outputs of the image block fine-tuning module and the structural feature fine-tuning module, and implements feature enhancement through a lightweight multi-layer perceptron, such as Figure 3 As shown in (d) in the figure. Set f m is the direct sum of f1 and f2, and the adapter module outputs f k It can be expressed as:

[0110]

[0111] Among them, k is the k-th Transformer block in the corresponding image encoder.

[0112] In a further preferred embodiment, the above S3, the refined training (optimization) strategy, specifically includes:

[0113] S31, freeze the original pre-trained parameters of the image encoder, and only use the parameters in the comprehensive web segmentation adaptive fine-tuning module for training. This step ensures that the focus of model training is on the newly introduced fine-tuning module to maintain the stability of the already trained basic features while increasing the adaptability to new data.

[0114] S32, fine-tunes the structure of the mask decoder to adapt to the image embedding vector obtained from the image encoder and optimizes the generation of the predicted mask. This process includes the use of customized loss functions that are specifically designed to improve segmentation accuracy and the performance of the model in real applications.

[0115] In a preferred embodiment of S3, the following operations may be referred to:

[0116] S31: During the training phase, the pre-trained parameters of the image encoder are frozen, and the focus is on optimizing the parameters of the adaptive fine-tuning module for comprehensive web segmentation in S2. The optimizer used is AdamW, and the initial learning rate is set to 2e-4, which is adjusted through the cosine annealing strategy as the training progresses. This step ensures that the focus of model training is on the newly introduced fine-tuning module to maintain the stability of the already trained basic features while increasing the adaptability to new data.

[0117] S32: Fine-tune the mask decoder to adapt to the web page image characteristics, and use the combined loss function (the weighted sum of the cross entropy loss and the IoU loss) for optimization to further improve the accuracy of web page segmentation. For example, when fine-tuning the mask decoder, the learning rate can be further reduced to 1e-5 to ensure the stability of the fine-tuning process. This improves the segmentation accuracy and the performance of the model in practical applications.

[0118] In a further preferred embodiment, the above S41, the spatial context collaborative segmentation and fusion module, specifically includes:

[0119] S411, spatial analysis is performed on the obtained bounding boxes to identify bounding boxes with high overlap. This process includes calculating the position and size of each bounding box and the overlapping area between them.

[0120] S412, based on the spatial analysis result, merging overlapping or adjacent bounding boxes into a single bounding box to reduce duplication and improve the overall accuracy of the result. This process not only considers the spatial position of the bounding box, but also ensures the visual consistency and optimal position of the merged bounding box.

[0121] In a preferred embodiment of S41, if Figure 4 As shown, the spatial context collaborative segmentation fusion module can refer to the following operations:

[0122] S411: Spatial analysis and bounding box evaluation. At this stage, each obtained bounding box is first spatially analyzed to calculate its position and size. This involves analyzing the four coordinate points of the bounding box to determine the specific position and range of each box in the image. Then, the overlapping area is evaluated by calculating the intersection and union ratio (IoU) between the bounding boxes to evaluate the degree of overlap between them. When the IoU of two boxes exceeds the set threshold (such as 0.5), these boxes will be marked as merge candidates and require further processing.

[0123] S412: Merging of bounding boxes. Based on the analysis results of S411, merging measures are taken to unify overlapping or adjacent bounding boxes into a single bounding box. The merging operation ensures the optimal integration of the bounding boxes, where the coordinates of the new bounding box are defined by the boundaries of all boxes involved in the merge, that is, the smallest x1, the largest x2, the smallest y1, and the largest y2 are taken as the coordinates of the new box. In addition, to ensure visual consistency and ensure that the bounding box is in the optimal position, the merging strategy also includes selecting the category of the box with the highest confidence as the category of the new box. This step not only emphasizes the accuracy of the merged box, but also achieves the effect of maximizing the target through possible position adjustments.

[0124] In a further preferred embodiment, the above S42, the OCR-driven text boundary refinement module, specifically includes:

[0125] S421, OCR text recognition and processing, using OCR technology to recognize the text in the web page and perform preliminary processing on the obtained text. This step includes text recognition, extraction and preprocessing to provide accurate input data for subsequent text analysis.

[0126] S422, text box clustering and density calculation, clustering analysis is performed on the obtained text boxes through the DBSCAN algorithm to identify text dense areas. This step helps determine the hot spots of text distribution and provides a basis for adjusting the bounding box.

[0127] S423, segmentation frame adjustment, adjusting the position and size of the segmentation frame according to the clustering and distribution of the text frame to ensure that the segmentation frame can more accurately cover the relevant text area. This step optimizes the accuracy of the segmentation result, making the final web page segmentation more consistent with the actual text layout.

[0128] In a preferred embodiment of S42, if Figure 5 As shown, the OCR-driven text boundary refinement module can refer to the following operations:

[0129] S421, OCR text recognition and processing. In this stage, OCR technology is used to recognize the text in the web page and the obtained text is preliminarily processed. This includes text recognition, that is, parsing the text content in the image through OCR technology. The extracted text is then preprocessed, including format standardization and denoising, to ensure clean and accurate input data for subsequent text analysis.

[0130] S422, text box clustering and density calculation. The extracted text boxes are clustered using the DBSCAN algorithm. The parameters of this algorithm are set as follows: the neighborhood radius (eps) is set to 10 pixels, which means that any two text box center points that are 10 pixels or closer are considered to be neighboring elements. The minimum number of sample points (min_samples) is set to 2, which means that a valid cluster must contain at least 2 text boxes. This setting helps identify text-dense areas, that is, areas where text boxes are more concentrated, and these areas will be focused on in subsequent bounding box adjustments.

[0131] S423, based on the clustering results and density information of the text boxes, the position and size of the segmentation box are adjusted. According to the clustering results, the extension margin of each segmentation box is dynamically adjusted according to the text density of the cluster in which it is located. The basic extension margin is set to 10 pixels, which is used for default extension when the text box clusters are particularly dense. For the density of the cluster where the segmentation box is located, a strategy is adopted in which the density is inversely proportional to the extension margin: the higher the density, the smaller the extension margin. Such an adjustment strategy helps to reduce unnecessary expansion of the bounding box while retaining important text information and improve the accuracy of segmentation.

[0132] An embodiment of the present invention provides a web page segmentation and adaptation system.

[0133] Specifically, Figure 6 As shown, the web page segmentation and adaptation system provided in this embodiment may include the following modules:

[0134] A segmentation model module, which is used to provide a pre-trained general visual segmentation model;

[0135] A comprehensive fine-tuning module, which is used to introduce a comprehensive web page segmentation adaptive fine-tuning module into the image encoder part of the pre-trained general visual segmentation model;

[0136] A refinement training module, which uses the comprehensive webpage segmentation adaptive fine-tuning module to perform refinement training on the pre-trained general visual segmentation model and structurally fine-tune the mask decoder part of the pre-trained general visual segmentation model to obtain a refined general visual segmentation model;

[0137] The post-processing module is used to post-process the visual segmentation results of the refined general visual segmentation model, merge overlapping segmentation frames, and refine and correct the segmentation frame positions to obtain the final segmentation results.

[0138] It should be noted that the steps in the method provided by the present invention can be implemented by using corresponding modules, devices, units, etc. in the system. Those skilled in the art can refer to the technical solution of the method to realize the composition of the system, that is, the embodiments in the method can be understood as preferred examples for constructing the system, which will not be elaborated here.

[0139] An embodiment of the present invention also provides an efficient web page segmentation and adaptation device, comprising at least one processor, at least one memory, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, it can be used to execute any method of the above-mentioned embodiments of the present invention, or run any system of the above-mentioned embodiments of the present invention.

[0140] Optionally, the memory is used to store programs; the memory may include volatile memory (English: volatile memory), such as random-access memory (English: random-access memory, abbreviated: RAM), such as static random-access memory (English: static random-access memory, abbreviated: SRAM), double data rate synchronous dynamic random access memory (English: Double Data Rate Synchronous Dynamic Random Access Memory, abbreviated: DDR SDRAM), etc.; the memory may also include non-volatile memory (English: non-volatile memory), such as flash memory (English: flash memory). The memory is used to store computer programs (such as applications, functional modules, etc. that implement the above method), computer instructions, etc., and the above computer programs, computer instructions, etc. can be partitioned and stored in one or more memories. And the above computer programs, computer instructions, data, etc. can be called by the processor.

[0141] The above-mentioned computer programs, computer instructions, etc. may be stored in one or more memories in partitions, and the above-mentioned computer programs, computer instructions, data, etc. may be called by a processor.

[0142] The processor is used to execute the computer program stored in the memory to implement the various steps of the method or various modules of the system involved in the above embodiments. For details, please refer to the relevant descriptions in the above method and system embodiments.

[0143] The processor and the memory may be independent structures or integrated structures. When the processor and the memory are independent structures, the memory and the processor may be coupled and connected via a bus.

[0144] An embodiment of the present invention further provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, it can be used to execute any method of the above embodiments of the present invention, or to run any system of the above embodiments of the present invention.

[0145] The web page segmentation adaptation method, system, device and medium provided by the above-mentioned embodiments of the present invention adopt efficient web page segmentation adaptation technology to overcome the limitations of general visual segmentation models in this field. By introducing comprehensive web page segmentation adaptive fine-tuning technology, the present invention not only optimizes the alignment between the pre-trained model and the target data set, but also significantly improves the model's characterization ability for specific web page content by analyzing and utilizing the structural features of the web page. The introduced post-processing technology further enhances the practicality and accuracy of the training model output. After the model training is completed, the post-processing technology can more accurately merge overlapping segmentation boxes and adjust the position of the boundary box according to the text data through spatial context collaborative segmentation fusion technology and OCR-driven text boundary refinement technology. These technologies not only improve the accuracy of the segmentation results, but also make the model more accurate and efficient in actual application scenarios such as web page content retrieval and analysis.

[0146] It will be appreciated by those skilled in the art that embodiments of the present invention may be provided as methods or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0147] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0148] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0149] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.

[0150] Although the preferred embodiments of the present invention have been described, those skilled in the art may make other changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the present invention.

[0151] Obviously, those skilled in the art can make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include these modifications and variations.

[0152] All matters not covered in the above embodiments of the present invention are well known in the art.

[0153] The above describes the specific embodiments of the present invention. It should be understood that the present invention is not limited to the above specific embodiments, and those skilled in the art may make various modifications or variations within the scope of the claims, which do not affect the essence of the present invention.

Claims

1. A web page segmentation and adaptation method, characterized in that: include: Provide a pre-trained general visual segmentation model; In the image encoder part of the pre-trained general visual segmentation model, a comprehensive web page segmentation adaptive fine-tuning module is provided; Using the comprehensive webpage segmentation adaptive fine-tuning module, the pre-trained general visual segmentation model is refined and trained, and the mask decoder part of the pre-trained general visual segmentation model is structurally fine-tuned to obtain a refined general visual segmentation model; The visual segmentation result output by the refined general visual segmentation model is post-processed to merge overlapping segmentation frames and refine and correct the position of the segmentation frames to obtain a final segmentation result.

2. The web page segmentation and adaptation method according to claim 1, characterized in that: The method provides a pre-trained general visual segmentation model, comprising: A general visual segmentation model is provided, and a parameter file of the general visual segmentation model is trained using a public training data set to obtain a pre-trained general visual segmentation model.

3. The webpage segmentation and adaptation method according to claim 1, characterized in that: In the image encoder part of the pre-trained general visual segmentation model, a comprehensive web page segmentation adaptive fine-tuning module is provided, including: A comprehensive web page segmentation adaptive fine-tuning module is introduced into the image encoder part of the general visual segmentation model, and the module includes: an image block fine-tuning module, a structural feature fine-tuning module and an adapter module; wherein: The image block fine-tuning module projects the original image embedding from a high-dimensional space into a reduced-dimensional feature space through an adjustable linear layer, so as to optimize the alignment between the pre-trained model and the target dataset; The structural feature fine-tuning module pre-processes the input web page image and converts it into a grayscale image, calculates the gradient amplitude using the Sobel operator to identify the edge and structural features in the web page image; segments the obtained edge and structural features into non-overlapping image blocks consistent with the general visual segmentation model, and projects these image blocks into a feature space with reduced dimensionality using an adjustable linear layer to optimize the structural representation of the web page image; The adapter module combines the outputs of the image segmentation fine-tuning module and the structural feature fine-tuning module, and uses a lightweight multi-layer perceptron to perform feature enhancement for a specific web page domain.

4. The web page segmentation and adaptation method according to claim 1, characterized in that: The integrated webpage segmentation adaptive fine-tuning module is used to perform fine-tuning on the pre-trained general visual segmentation model, and the mask decoder part of the pre-trained general visual segmentation model is structurally fine-tuned, including: Freezing some parameters of the image encoder of the pre-trained general visual segmentation model, and training the pre-trained general visual segmentation model using only the parameters in the comprehensive web page segmentation adaptive fine-tuning module; The structure of the mask decoder part of the pre-trained general visual segmentation model is fine-tuned to adapt the image embedding vector obtained from the image encoder part.

5. The web page segmentation and adaptation method according to claim 1, characterized in that: The post-processing of the visual segmentation result output by the refined general visual segmentation model, merging overlapping segmentation frames and refining and correcting the position of the segmentation frames, includes: A post-processing module is introduced at the output end of the refined general visual segmentation model, and the post-processing module includes: a spatial context collaborative segmentation fusion module and an OCR-driven text boundary refinement module, wherein the spatial context collaborative segmentation fusion module is used to merge the overlapping segmentation boxes in the visual segmentation results output by the refined general visual segmentation model; the OCR-driven text boundary refinement module uses the text data extracted from the OCR technology to refine and correct the position of the segmentation box.

6. The webpage segmentation and adaptation method according to claim 5, characterized in that: The spatial context collaborative segmentation fusion module is used to merge overlapping segmentation frames in the visual segmentation results output by the refined general visual segmentation model, and includes: Perform spatial analysis on the obtained bounding boxes to calculate the position, size and overlapping area of ​​each bounding box; According to the spatial analysis results, the overlapping or adjacent bounding boxes are merged into a single bounding box, completing the merging of the overlapping segmentation boxes in the visual segmentation results.

7. The webpage segmentation and adaptation method according to claim 5, characterized in that: The OCR-driven text boundary refinement module uses text data extracted from the OCR technology to refine and correct the position of the segmentation box, including: Use OCR technology to identify text data in web page images and obtain corresponding text boxes; Performing cluster analysis on the text frame using the DBSCAN algorithm to identify the regional distribution of the text data; According to the clustering of the text boxes and the distribution results of the text data, the position and size of the segmentation box are adjusted to ensure that the segmentation box can accurately cover the relevant text data area.

8. A web page segmentation and adaptation system, characterized in that: include: A segmentation model module, which is used to provide a pre-trained general visual segmentation model; A comprehensive fine-tuning module, the module is used to introduce a comprehensive web page segmentation adaptive fine-tuning module into the image encoder part of the pre-trained general visual segmentation model; A refinement training module, which utilizes the comprehensive webpage segmentation adaptive fine-tuning module to perform refinement training on the pre-trained general visual segmentation model, and performs structural fine-tuning on the mask decoder part of the pre-trained general visual segmentation model to obtain a refined general visual segmentation model; A post-processing module is used to post-process the visual segmentation result output by the refined general visual segmentation model, merge overlapping segmentation frames, and refine and correct the position of the segmentation frames to obtain the final segmentation result.

9. A web page segmentation and adaptation device, comprising at least one processor, at least one memory, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, it can be used to perform the method described in any one of claims 1 to 7, or to run the system described in claim 8.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, it can be used to perform the method described in any one of claims 1 to 7, or to run the system described in claim 8.