High-efficiency high-resolution image visual mark generation method for multi-modal large model
Through dynamic slicing and cross-attention processing, compressed visual mark sequences are generated, which solves the problem of increased computing and memory requirements of multi-modal large language models in high-resolution image processing, improves the efficiency and performance of the model, and is suitable for needs Scenarios for fine-grained visual understanding.
Patent Information
- Application Number
- CN202410870933.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-01
- Publication Date
- 2024-10-01
- Estimated Expiration
- 2044-07-01
AI Technical Summary
When existing multi-modal large language models process high-resolution images, the length of the visual marker sequence increases significantly, resulting in increased computing and memory requirements, and it is difficult to retain the detailed information of high-resolution images, affecting visual reasoning capabilities, and existing This method can easily lead to blurring or deformation when resizing the image, which wastes computing resources.
The dynamic slicing method based on minimum filling is used to segment the large-resolution image, generate several image blocks, and use the visual encoder to extract multi-layer visual features and single-layer low-resolution features, and generate compressed vision through cross-attention and connection processing. Marker sequences that support input images with arbitrary aspect ratios.
It effectively compresses the length of the visual marker sequence, improves the overall performance and efficiency of multi-modal large models, and retains the detailed information of high-resolution images. It is suitable for tasks that require fine-grained visual understanding, such as OCR recognition and complex visual reasoning.
Smart Images

Figure CN118735932A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to a visual tag generation method for a multimodal large language model, and in particular to a visual tag generation method for a multimodal large model that efficiently supports large-resolution images. Background Art
[0002] With the rapid development of large language models, multimodal large language models have made significant progress in visual-language understanding, reasoning, and interaction capabilities. By projecting the output features of the visual encoder into the large language model, it is enabled to perceive the visual world, and the visual projector plays a key role in connecting the visual model and the language model. In the current multimodal large language model framework, the computational and memory requirements are mainly driven by the language model with a large number of parameters. The visual encoder is usually much smaller than the language model. Therefore, the length of the visual tag sequence generated by the visual projector significantly affects the overall efficiency of the multimodal large language model.
[0003] Most methods adopt linear projectors or resamplers. For linear projectors, multi-layer perceptron projection preserves all visual context through a one-to-one transformation, thereby retaining detailed information including redundant tags. This is significant when processing high-resolution images or videos, where the length of visual tag sequences increases significantly.
[0004] In addition, there are also methods that use resamplers or Q-Former methods to explicitly control the length of the visual tag sequence using a set of learnable queries, and use cross-attention layers to force the extraction of the most relevant visual cues from the visual features. At the same time, some methods use convolutional layers to encourage local interactions of visual features and generate compressed tags. However, these methods inevitably lose detail information and sacrifice the visual reasoning ability of multimodal large language models. In addition, some methods directly transfer visual features from the length dimension to the channel dimension through simple pixel shuffling or neighbor splicing operations to reduce the sequence length. Although all information is retained, the structural characteristics of the visual features themselves may be destroyed.
[0005] Most current large multimodal models use CLIP-ViT as a visual encoder to capture visual information, which is limited by low-resolution inputs, such as only supporting images with a resolution of 224*224 or 336*336, making it difficult for large multimodal models to handle tasks that require fine details, such as dense OCR, object counting, visual localization of small objects, etc. Existing methods directly use SAM or ConvNeXt encoders that support high-resolution inputs to directly merge high-resolution features with original low-resolution features.
[0006] There are also methods that resize the image to an accessible size and use a sliding window to split the image into blocks of the same size (such as 224*224). Although these methods change the original resolution to a fixed square size, this may cause blurry or distorted visual content. There are also methods that use similar aspect ratios instead of fixed square ratios for adjustment. Nevertheless, there are still inevitable image adjustment and padding operations, which may cause image deformation and waste of computing resources. Summary of the invention
[0007] In order to solve the problems existing in the background technology, the present invention proposes a method for efficiently supporting large-resolution image visual tag generation for a multimodal large model. The present invention first dynamically slices and divides the large-resolution image, and then injects multi-level high-resolution visual features into the low-resolution query to generate a compressed visual tag sequence. This method of the present invention supports input images with arbitrary aspect ratios, effectively compresses the length of the visual tag sequence, and can improve the overall performance and efficiency of the multimodal large model.
[0008] The technical solution adopted by the present invention comprises the following steps:
[0009] 1. An Efficient Large-Resolution Image Visual Labeling Method for Multimodal Large Models
[0010] S1: After performing image segmentation based on the original aspect ratio of the input original image using a dynamic slicing method based on minimum padding, a plurality of image blocks are obtained; and after preprocessing the original image, the size of the image block is the same as that of the image block, thereby obtaining image blocks corresponding to the original image and forming a set of image blocks to be processed with the image blocks obtained by segmentation;
[0011] S2: using a visual encoder to extract multi-layer visual features of each image block in the set of image blocks to be processed, and extracting single-layer low-resolution features;
[0012] S3: According to the multi-layer visual features and single-layer low-resolution features of the current image block, after cross-attention and connection processing, a visual marker subsequence of the current image block is obtained;
[0013] S4: Repeat S2 and S3, generate visual labels for the remaining image blocks in the image block set to be processed, obtain all visual label subsequences, and then generate a compressed visual label sequence of the original image.
[0014] In S1, the original image is an image with any aspect ratio, and the resolution of the original image includes a large resolution.
[0015] In S1, after performing image segmentation based on the original aspect ratio on the input original image using the dynamic slicing method based on minimum filling, a plurality of image blocks are obtained, specifically:
[0016] According to the size of the input original image and the preset size of the image block, the following formula is used to solve the parameters of the segmentation grid, including the number of rows and columns of the segmentation grid:
[0017]
[0018] S o (H, W, r, n H , n W )=IoU((H,W),(n H ×r,n W ×r))
[0019]
[0020] Among them, n H *, n W * are the actual number of rows and columns of the segmented grid, n H and n W is the number of rows and columns of the partition grid, N g represents the maximum number of grids; r represents the preset size of the image block, S p ( ) and S o ( ) are the filling fraction and overlap fraction, H and W are the height and width of the original image, IoU ( ) is the intersection over union ratio of the image, To split the grid configuration, is an integer set, β is the weight coefficient, and α is the image adjustment ratio;
[0021] Then, according to the actual number of rows and columns of the segmentation grid, the input original image is segmented to obtain a number of image blocks, and then the image blocks with a size smaller than the preset size are filled to obtain the final image block.
[0022] In S1, the original image is resized and pixel-filled to make it the same size as the image block.
[0023] In S2, the penultimate layer of visual features output from the visual encoder is downsampled to obtain a single layer of low-resolution features.
[0024] The S3 is specifically:
[0025] The multi-layer visual features of the current image block are deformed and flattened after passing through the multi-layer perceptron to obtain multi-scale high-resolution features and serve as the key and value of the cross-attention mechanism. The single-layer low-resolution features of the current image block are flattened and used as the query of the cross-attention mechanism. Then, a multi-layer injection process based on cross-attention is performed to obtain the visual marker subsequence of the current image block.
[0026] The multi-layer injection process based on cross attention is specifically as follows:
[0027] A criss-cross attention operation is performed to obtain the output of the criss-cross attention mechanism module and use it as the input of the connector, which generates a subsequence of visual markers for the current image block.
[0028] In S4, a line break is added at the end of each visual marker subsequence, and a separator is added between two adjacent visual marker subsequences, so that all visual marker subsequences are concatenated to generate a compressed visual marker sequence of the original image.
[0029] In S2, the visual encoder is specifically a CLIP-VIT-L / 14 visual encoder.
[0030] The connector is a multi-layer perceptron.
[0031] The delimiter includes a comma.
[0032] 2. An Efficient Large-Resolution Image Visual Labeling System for Multimodal Large Models
[0033] A dynamic slicing module is used to perform image segmentation and preprocessing on the original image based on the original aspect ratio to obtain a set of image blocks to be processed;
[0034] A visual feature extraction module, used to extract visual features of image blocks using a visual encoder;
[0035] The visual marker sequence generation module is used to generate a visual marker subsequence of each image block by using the multi-layer injection module, and generate a compressed visual marker sequence according to the visual marker subsequence.
[0036] 3. A computer device
[0037] The computer device comprises a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the method when executing the computer program.
[0038] 4. A computer-readable storage medium
[0039] The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the method described are implemented.
[0040] The beneficial effects of the present invention are:
[0041] The present invention proposes a method for efficiently generating visual tags for large-resolution images for multimodal large models, which can generate a concise visual tag sequence between the visual encoder and the language model. The high-resolution visual features are downsampled to low-resolution visual features through interpolation as the basis for the overall visual representation. Through a multi-layer injection module, a single layer of low-resolution features is used as a query, and multiple layers of high-resolution visual features are used as reference keys and values to ensure that detailed information is fully absorbed in the corresponding local context area, effectively updating the low-resolution query and transforming it into a rich representation.
[0042] The present invention has significant advantages in achieving efficient large-resolution image understanding and visual reasoning of multimodal large language models, and provides an efficient and fine-grained solution for future vision-language model research. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] Figure 1 It is an overall flow chart of an efficient method for generating visual markers for large-resolution images for a multimodal large model according to an embodiment of the present invention.
[0044] Figure 2 It is a flow chart of the image dynamic slicing module according to an embodiment of the present invention.
[0045] Figure 3 This is a schematic diagram of a visual projector network that efficiently supports large-resolution image visual marker generation according to an embodiment of the present invention. DETAILED DESCRIPTION
[0046] The technical solution of the present invention will be described clearly and completely below in conjunction with the accompanying drawings of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in the field without creative work are within the scope of protection of the present invention.
[0047] In order to make the objectives, technical solutions and advantages of the present invention more clearly understood, embodiments of the present invention will be described in detail with reference to the accompanying drawings.
[0048] like Figure 1 and Figure 2 As shown, on the one hand, the present invention proposes a method for efficiently generating visual tags for multimodal large models that supports large-resolution images, comprising the following steps:
[0049] S1: After performing image segmentation based on the original aspect ratio of the input original image using a dynamic slicing method based on minimum padding, a number of image blocks are obtained; and after preprocessing the original image, the size of the image block is made the same as that of the image block, thereby obtaining image blocks corresponding to the original image and forming a set of image blocks to be processed with the image blocks obtained by segmentation;
[0050] The original image is an image of any aspect ratio, and the resolution of the original image includes a large resolution and a small resolution. The small resolution refers to 336x336 or 224x224, which is the input image resolution of CLIP-ViT itself. The opposite is a large resolution. The present invention can support a resolution of 1088x1088 or 1344x1344 or larger.
[0051] In S1, the input original image is segmented based on the original aspect ratio using the dynamic slicing method based on minimum filling, and several image blocks are obtained, specifically:
[0052] According to the size of the input original image and the preset size of the image block (that is, 336 specified in the CLIP-ViT-L / 14 image encoder), the following formula is used to solve the parameters of the segmentation grid, including the number of rows and columns of the segmentation grid:
[0053]
[0054] S o (H, W, r, n H , n W )=IoU((H,W),(n H ×r,n W ×r))
[0055]
[0056] Among them, n H *, n W * are the actual number of rows and columns of the segmented grid, n G and n W is the number of rows and columns of the partition grid, N g represents the maximum number of grids allowed; r represents the preset size of the image block, S p ( ) and S o ( ) are the filling score and overlap score, H, W are the height and width of the original image, IoU((H, W), (n H ×r,n W ×r)) is the intersection-over-union ratio of the original image and the large image after segmentation, For different segmentation grid configurations, is an integer, β is the weight coefficient, and α is the image adjustment ratio;
[0057] Then, according to the actual number of rows and columns of the segmentation grid, the input original image is segmented to obtain several image blocks, and then the image blocks with a size smaller than the preset size are filled to obtain the final image block. The above formula obtains the given image The optimal segmentation grid configuration of considers three key factors: 1) maintaining the original aspect ratio of the original image to avoid distortion; 2) minimizing the padding ratio so that most of the grids are occupied by the original image content; 3) among the segmentation grid configurations that satisfy the first two conditions, the configuration with the resolution closest to the original image is selected.
[0058] On the basis of keeping the original aspect ratio unchanged, the original image is resized (i.e., scaled) and filled with zero pixels according to the image adjustment ratio to make it the same size as the image block as a macro overview of the original image to retain the original information.
[0059] S2: using a visual encoder to extract multi-layer visual features of each image block in the set of image blocks to be processed, and extracting single-layer low-resolution features;
[0060] like Figure 3 As shown in S2, bilinear interpolation is used to downsample the penultimate visual features of the output of the visual encoder (i.e., the penultimate visual features of the Transformer in the CLIP-VIT-L / 14 visual encoder) to obtain a single-layer low-resolution feature. Specifically, bilinear interpolation is used to downsample the penultimate visual features of the Transformer in the CLIP-ViT-L / 14-336px visual encoder by a scaling factor s. Downsampling to low-resolution visual features in N is the length of the visual feature, C is the dimension of the visual feature, and the visual marker sequence length M can be controlled by the downsampling ratio s. Low-resolution visual feature I′ v It can be regarded as a coarse representation of the original high-resolution visual features, where the low-resolution feature I′ v Each pixel corresponds to a high-resolution feature I v A specific (s*s) sub-region of .
[0061] S3: According to the multi-layer visual features and single-layer low-resolution features of the current image block, after cross-attention and connection processing, a visual marker subsequence of the current image block is obtained;
[0062] S3 is specifically:
[0063] The present invention constructs low-resolution features Each pixel in the The pairing relationship of each sub-region in (where s represents the scaling factor, M represents the length of the low-resolution feature, and s 2 ×M is the length of the high-resolution feature), thereby injecting detailed information of the high-resolution sub-region into each pixel roughly represented by the low resolution. Therefore, the multi-layer visual features of the current image block are deformed and flattened after passing through the multi-layer perceptron (MLP) to obtain multi-scale high-resolution features and serve as the key and value of the cross-attention mechanism. The single-layer low-resolution features of the current image block are flattened as the query of the cross-attention mechanism, and then a multi-layer injection process based on the cross-attention is performed to obtain the visual marker subsequence of the current image block.
[0064] The multi-layer injection processing based on cross attention is as follows:
[0065] Perform cross-attention operation to inject multiple layers of high-resolution detail information into low-resolution features, obtain the output of the cross-attention mechanism module and use it as the input of the connector, which generates a visual marker subsequence of the current image block. The multi-layer injection process based on cross-attention is a multi-layer injection module. Since different layers of the CLIP-VIT visual encoder show different biases for different modes. Shallow features contain low-level information, while deep features perform better in semantic understanding. Therefore, the single-layer low-resolution features are flattened as queries, and the multi-layer high-resolution features are passed through MLP, deformed and flattened as candidate values and keys for reference. The cross-attention operation allows the low-resolution features to fully absorb the fine-grained high-resolution feature information. The features are then converted into visual marker subsequences through a connector composed of a multi-layer perceptron.
[0066] S4: Repeat S2 and S3, generate visual markers for the remaining image blocks in the image block set to be processed, obtain all visual marker subsequences, and then generate a compressed visual marker sequence (tokens) of the original image, which is specifically generated by concatenating the visual marker subsequences corresponding to all the image blocks.
[0067] In S4, a line break ('\n') is added at the end of each visual marker subsequence, and a separator (such as a comma (',')) is added between two adjacent visual marker subsequences to represent the two-dimensional structural information of the image to avoid ambiguity in the large language model, so that all visual marker subsequences are concatenated to generate a compressed visual marker sequence of the original image. The length of the compressed visual marker sequence generated by the present invention is 1 / s of the visual marker sequence before compression. 2 , and it is a high-quality visual tag sequence, which can be used for reasoning tasks of large language models.
[0068] On the one hand, the present invention proposes an efficient large-resolution image visual tag generation system for a multimodal large model, comprising:
[0069] A dynamic slicing module is used to perform image segmentation and preprocessing on the original image based on the original aspect ratio to obtain a set of image blocks to be processed;
[0070] A visual feature extraction module, used to extract visual features of image blocks using a visual encoder;
[0071] The visual marker sequence generation module is used to generate a visual marker subsequence of each image block by using the multi-layer injection module, and generate a compressed visual marker sequence according to the visual marker subsequence.
[0072] In one aspect, the present invention provides a computer device, comprising a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the method when executing the computer program.
[0073] In one aspect, the present invention provides a computer-readable storage medium having a computer program stored thereon, which implements the steps of the method when the computer program is executed by a processor.
[0074] Large Language Model Also accepts visual markers T v and text mark T t , and autoregressively generate coherent responses. For a response sequence of length L, generate the contextual target answer The probability can be calculated by the following formula:
[0075]
[0076] Among them, p( ) is the probability of generating the target answer, y i is the i-th word in the target answer sequence.
[0077] The present invention proposes a method for efficiently generating visual tags for large-resolution images for multimodal large models, which can effectively compress the length of visual tag sequences while retaining the rich detail information of high-resolution images, thereby greatly improving the efficiency and performance of multimodal large language models. By interpolating low-resolution features and injecting multiple layers of high-resolution features, a streamlined visual tag sequence is generated, and high-quality feature conversion is achieved between the visual encoder and the large language model. The method of the present invention overcomes the shortcomings of traditional methods in high-resolution image processing, and is particularly suitable for scenarios that require fine-grained visual understanding, such as OCR recognition and complex visual reasoning, and is therefore conducive to the implementation of multimodal large models in practical applications.
[0078] Finally, it should be noted that the above embodiments and explanations are only used to illustrate the technical solution of the present invention rather than to limit it. Those skilled in the art should understand that the technical solution of the present invention can be modified or replaced by equivalents without departing from the spirit and scope disclosed in the technical solution of the present invention, which should be included in the scope of protection of the claims of the present invention.
Claims
1. An efficient large-resolution image visual tag generation method for multimodal large models, characterized in that: The following steps are involved: S1: After performing image segmentation based on the original aspect ratio of the input original image using a dynamic slicing method based on minimum padding, a plurality of image blocks are obtained; and after preprocessing the original image, the size of the image block is the same as that of the image block, thereby obtaining image blocks corresponding to the original image and forming a set of image blocks to be processed with the image blocks obtained by segmentation; S2: using a visual encoder to extract multi-layer visual features of each image block in the set of image blocks to be processed, and extracting single-layer low-resolution features; S3: According to the multi-layer visual features and single-layer low-resolution features of the current image block, after cross-attention and connection processing, a visual marker subsequence of the current image block is obtained; S4: Repeat S2 and S3, generate visual labels for the remaining image blocks in the image block set to be processed, obtain all visual label subsequences, and then generate a compressed visual label sequence of the original image.
2. The method for generating high-efficiency and high-resolution image visual markers for a multimodal large model according to claim 1, characterized in that: In S1, the original image is an image with any aspect ratio, and the resolution of the original image includes a large resolution.
3. The method for generating high-efficiency and high-resolution image visual markers for a multimodal large model according to claim 1, characterized in that: In S1, after performing image segmentation based on the original aspect ratio on the input original image using the dynamic slicing method based on minimum filling, a plurality of image blocks are obtained, specifically: According to the size of the input original image and the preset size of the image block, the following formula is used to solve the parameters of the segmentation grid, including the number of rows and columns of the segmentation grid: S o (H,W,r,n H ,n w )=IoU((H,W),(n H ×r,n W ×r)) Among them, n H *, n W * are the actual number of rows and columns of the segmented grid, n H and n W is the number of rows and columns of the partition grid, N g represents the maximum number of grids; r represents the preset size of the image block, S p ( ) and S o ( ) are the filling fraction and overlap fraction, H and W are the height and width of the original image, IoU ( ) is the intersection over union ratio of the image, To split the grid configuration, is an integer set, β is the weight coefficient, and α is the image adjustment ratio; Then, according to the actual number of rows and columns of the segmentation grid, the input original image is segmented to obtain a number of image blocks, and then the image blocks with a size smaller than the preset size are filled to obtain the final image block.
4. The method for generating high-efficiency and high-resolution image visual markers for a multimodal large model according to claim 1, characterized in that: In S1, the original image is resized and pixel-filled to make it the same size as the image block.
5. The method for generating high-efficiency and high-resolution image visual markers for a multimodal large model according to claim 1, characterized in that: In S2, the penultimate layer of visual features output from the visual encoder is downsampled to obtain a single layer of low-resolution features.
6. The method for generating high-efficiency and high-resolution image visual markers for a multimodal large model according to claim 1, characterized in that: The S3 is specifically: The multi-layer visual features of the current image block are deformed and flattened after passing through the multi-layer perceptron to obtain multi-scale high-resolution features and serve as the key and value of the cross-attention mechanism. The single-layer low-resolution features of the current image block are flattened and used as the query of the cross-attention mechanism. Then, a multi-layer injection process based on cross-attention is performed to obtain the visual marker subsequence of the current image block.
7. The method for generating high-efficiency and high-resolution image visual markers for a multimodal large model according to claim 6, characterized in that: The multi-layer injection process based on cross attention is specifically as follows: A criss-cross attention operation is performed to obtain the output of the criss-cross attention mechanism module and use it as the input of the connector, which generates a subsequence of visual markers for the current image block.
8. The method for generating high-efficiency and high-resolution image visual markers for a multimodal large model according to claim 1, characterized in that: In S4, a line break is added at the end of each visual marker subsequence, and a separator is added between two adjacent visual marker subsequences, so that all visual marker subsequences are concatenated to generate a compressed visual marker sequence of the original image.
9. An efficient large-resolution image visual tag generation system for multimodal large models, characterized in that: include: A dynamic slicing module is used to perform image segmentation and preprocessing on the original image based on the original aspect ratio to obtain a set of image blocks to be processed; A visual feature extraction module, used to extract visual features of image blocks using a visual encoder; The visual marker sequence generation module is used to generate a visual marker subsequence of each image block by using the multi-layer injection module, and generate a compressed visual marker sequence according to the visual marker subsequence.
10. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 8 are implemented.
Citation Information
Patent Citations
Method for recovering three-dimensional geometric information from image
CN101398933A
Gated cross word-visual attention driven text image generation method
CN115438211A
Visual analysis method and device
CN115761771A
Two-stage deep network image super-resolution reconstruction method suitable for multiple blurring kernels
CN116188272A
Image super-resolution method and system based on semantic reasoning and cross convolution
CN116934593A
Cited By
Image processing method and device, storage medium and computer program product
CN119559198A
Remote sensing image processing method, system and equipment based on knowledge graph and medium
CN119782479A
Implementation method of high-resolution multi-modal large model architecture
CN119887520A
Visual question and answer method and device based on multi-modal large model and medium
CN119938872A
A Visual Question Answering Method, Device and Medium Based on Multimodal Large Model
CN119938872B
