A pyramid network attention adjustment method and system for image processing

Through the pyramid network attention adjustment method and high-dimensional feature position encoding, the traditional network attention mechanism solves the problems of high computational complexity and insensitivity to multi-scale objects in image processing, achieving faster training speed and higher accuracy performance.

CN113989515BActive Publication Date: 2024-09-06SHANGHAI NORMAL UNIVERSITY
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202111204551.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-10-15
Publication Date
2024-09-06
Estimated Expiration
2041-10-15

AI Technical Summary

Technical Problem

The traditional network attention mechanism has high computational complexity and training difficulty in image processing, and is insensitive to multi-scale objects in images, which limits its application development.

Method used

The pyramid network attention adjustment method is used to adjust the size of the attention window through learnable position offsets, and divide it into pyramid modules. It combines Gaussian functions to encode high-dimensional feature positions to adapt to objects of different sizes.

Benefits of technology

It improves the training speed and image processing accuracy of the model, enhances the perception of multi-scale objects, and reduces the computational complexity.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113989515B
    Figure CN113989515B
Patent Text Reader

Abstract

The present invention relates to a pyramid network attention adjustment method and system for image processing, the method comprising a deformable attention mechanism adjustment step: adjusting the range and size of the attention window based on a learnable position bias, that is, loading the image to be processed into the neural network to obtain the position bias result; an attention pyramid network adjustment step: gradually dividing the size of the attention window according to the stage sequence of image processing; dividing the image to be processed into a plurality of block images, using a Gaussian function to positionally encode each block image, performing image processing on the block image according to the position code, and respectively executing the above-mentioned deformable attention mechanism adjustment step and attention pyramid network adjustment step. Compared with the prior art, the present invention not only has a faster training speed in the model training stage, but also has better accuracy performance and model robustness in the model reasoning and use stages.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of image processing technology, and in particular to a pyramid network attention adjustment method and system for image processing. Background Art

[0002] The network attention mechanism is an efficient feature processing technology that has been widely used in many fields such as natural language processing and image processing. However, the traditional network attention mechanism for image processing has problems such as high computational complexity, high training difficulty, and insensitivity to multi-scale objects in images. These problems have seriously restricted the development and application of this technology in the field of image processing. Summary of the invention

[0003] The purpose of the present invention is to overcome the defects of the above-mentioned prior art network attention mechanism, such as high computational complexity, great training difficulty, and insensitivity to multi-scale objects in images, and to provide a pyramid network attention adjustment method and system for image processing.

[0004] The purpose of the present invention can be achieved by the following technical solutions:

[0005] A pyramid network attention adjustment method for image processing, used for adjusting the size of an attention window during image processing, the method comprising the following steps:

[0006] The deformable attention mechanism adjustment step is as follows: adjusting the range and size of the attention window based on a learnable position bias, wherein the learnable position bias is obtained by loading the image to be processed into a pre-built and trained neural network to obtain a position bias result;

[0007] Attention pyramid network adjustment step: gradually divide the size of the attention window according to the stage order of image processing.

[0008] Furthermore, the calculation formula of the position offset is:

[0009]

[0010] In the formula, is the horizontal position offset of the attention window in the image, is the vertical position bias of the attention window in the image, Dense(·) is a fully connected network, Conv(·) is a convolutional neural network, W is the weight of the network, and f is the feature calculated by the previous layer of the network.

[0011] Furthermore, the deformable attention mechanism adjustment step also includes using an attention range truncation method to limit the size of the position bias.

[0012] Furthermore, the calculation expression of the attention range truncation method is:

[0013] C((x,y),(h,w))=(max(min(x+h,h),1),max(min(y+w,w),1))

[0014] Where x is the vertical offset, y is the horizontal offset, h is the height of the image to be processed, w is the width of the image to be processed, max(·) is the maximum value, and min(·) is the minimum value.

[0015] Furthermore, the attention pyramid network adjustment step specifically includes: dividing the attention window into one or more pyramid modules;

[0016] In the same stage of image processing, the attention window sizes between pyramid modules are multiples of each other;

[0017] In different stages of image processing, the attention window sizes of corresponding pyramid modules are multiples of each other.

[0018] Furthermore, the efficient pyramid network attention adjustment method also includes: dividing the image to be processed into a plurality of block images, and executing the deformable attention mechanism adjustment step and the attention pyramid network adjustment step on each block image respectively.

[0019] Furthermore, the efficient pyramid network attention adjustment method also includes:

[0020] High-dimensional feature position encoding step: use a Gaussian function to process the position of each block image, obtain a block image position code that satisfies the Gaussian function distribution, and perform image processing on the block image according to the block image position code.

[0021] Furthermore, the calculation expression for processing the position of each block image using the Gaussian function is:

[0022]

[0023] Where f(x) is the block image position code, x is the position of the block image, and a, b, and c are all real constants.

[0024] Furthermore, each block image is processed through the attention window, and the position bias of the attention window is calculated through the deformable attention mechanism adjustment step, the size of the attention window is adjusted through the attention pyramid network adjustment step, and then the attention window of the next image processing stage is adjusted, so as to perform image processing on each block image, and finally obtain the output result by iterating in sequence.

[0025] The present invention also provides an efficient pyramid network attention adjustment system for image processing, comprising a memory and a processor, wherein the memory stores a computer program, and the processor calls the computer program to execute the steps of the method described above.

[0026] Compared with the prior art, the present invention has the following advantages:

[0027] For the deformable attention mechanism adjustment step in the present invention, its characteristic is that it can effectively expand the receptive field of network attention without significantly increasing calculations; for the attention pyramid network adjustment step in the present invention, its characteristic is that it is conducive to processing objects of different sizes and dimensions in image data, thereby improving the performance of the model; for the high-dimensional feature position encoding step in the present invention, the position encoding is characterized by symmetry, data-driven, network calculation parallelism and parameter effectiveness.

[0028] The image processing model of the present invention not only has a faster training speed in the model training stage, but also has better accuracy performance and model robustness in the model reasoning and use stages. BRIEF DESCRIPTION OF THE DRAWINGS

[0029] Figure 1 A deformable attention mechanism flow chart provided for an embodiment of the present invention;

[0030] Figure 2 An attention pyramid flow chart provided for an embodiment of the present invention;

[0031] Figure 3 A high-dimensional feature position encoding flow chart provided for an embodiment of the present invention. DETAILED DESCRIPTION

[0032] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Generally, the components of the embodiments of the present invention described and shown in the drawings here can be arranged and designed in various different configurations.

[0033] Therefore, the following detailed description of the embodiments of the present invention provided in the accompanying drawings is not intended to limit the scope of the invention claimed for protection, but merely represents selected embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0034] It should be noted that similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, further definition and explanation thereof is not required in subsequent drawings.

[0035] Example 1

[0036] This embodiment provides a pyramid network attention adjustment method for image processing, which is used to adjust the size of the attention window during image processing. The method includes the following steps:

[0037] The deformable attention mechanism adjustment steps are as follows: adjusting the range and size of the attention window based on the learnable position bias. The learnable position bias is obtained by loading the image to be processed into a pre-built and trained neural network to obtain the position bias result;

[0038] Attention pyramid network adjustment steps: gradually divide the size of the attention window according to the order of image processing stages.

[0039] As a preferred embodiment, the method further comprises:

[0040] Divide the image to be processed into multiple block images, and perform the deformable attention mechanism adjustment step and the attention pyramid network adjustment step on each block image respectively;

[0041] High-dimensional feature position encoding step: use a Gaussian function to process the position of each block image, obtain a block image position code that satisfies the Gaussian function distribution, and perform image processing on the block image according to the block image position code.

[0042] Each step is described in detail below.

[0043] 1. Deformable attention mechanism adjustment steps

[0044] The deformable attention mechanism adjustment step learns a position bias for each attention window that can adjust the attention range and size.

[0045] The calculation formula for position offset is:

[0046]

[0047] In the formula, is the horizontal position offset of the attention window in the image, is the vertical position bias of the attention window in the image, Dense(·) is a fully connected network, Conv(·) is a convolutional neural network, W is the weight of the network, and f is the feature calculated by the previous layer of the network.

[0048] As a preferred implementation, the deformable attention mechanism adjustment step also includes using an attention range truncation method to limit the size of the position bias.

[0049] The calculation expression of the attention range truncation method is:

[0050] C((x,y),(h,w))=(max(min(x+h,h),1),max(min(y+w,w),1))

[0051] Where x is the vertical offset, y is the horizontal offset, h is the height of the image to be processed, w is the width of the image to be processed, max(·) is the maximum value, and min(·) is the minimum value.

[0052] 2. Attention Pyramid Network Adjustment Steps

[0053] The characteristic of the attention pyramid network adjustment step is to obtain attention of different sizes by adjusting the size of the attention window inside the network, which is beneficial for processing objects of different sizes and dimensions in the image data, thereby improving the performance of the model;

[0054] This step specifically includes: dividing the attention window into one or more pyramid modules;

[0055] In the same stage of image processing, the attention window sizes between pyramid modules are multiples of each other;

[0056] In different stages of image processing, the attention window sizes of corresponding pyramid modules are multiples of each other.

[0057] 3. High-dimensional feature position encoding steps

[0058] The high-dimensional feature position encoding step performs position encoding on the data to be encoded of any length and size based on a multi-dimensional Gaussian mixture model. The characteristics of this position encoding are symmetry, data-driven, network computing parallelism and parameter effectiveness.

[0059] The calculation expression for processing the position of each block image using the Gaussian function is:

[0060]

[0061] Where f(x) is the block image position code, x is the position of the block image, and a, b, and c are all real constants.

[0062] Image processing is performed on each block image through the attention window, and the position bias of the attention window is calculated through the deformable attention mechanism adjustment step. The size of the attention window is adjusted through the attention pyramid network adjustment step, and then the attention window of the next image processing stage is adjusted to perform image processing on each block image, and the output result is finally obtained by iterating in sequence.

[0063] The overall attention mechanism calculation formula is:

[0064]

[0065] In the formula, Q, K, and V represent different network branch results, that is, Query, Key, and Value, respectively.

[0066] like Figure 1 As shown, Figure 1 This is the deformable attention mechanism process of this embodiment. The deformable attention mechanism module provided by this embodiment can effectively expand the scope of attention extraction.

[0067] like Figure 2 As shown, Figure 2 This is the attention pyramid process of this embodiment. The attention pyramid provided by this embodiment can perceive multi-scale attention information.

[0068] like Figure 3 As shown, Figure 3 This is the high-dimensional feature position encoding process of this embodiment. The high-dimensional feature position encoding algorithm provided by this embodiment can perform position encoding on data of any length and any dimension.

[0069] In summary, this embodiment mainly includes three parts: first, a deformable attention mechanism adjustment process is proposed, which adjusts the range and size of attention based on the learnable position bias adjustment, and the characteristic is that the receptive field of network attention can be effectively expanded without significantly increasing the calculation; second, this embodiment proposes an attention pyramid network adjustment process, which is characterized by obtaining attention of different sizes by adjusting the size of the attention window inside the network, which is conducive to processing objects of different sizes and sizes in image data, thereby improving the performance of the model; third, this embodiment proposes a high-dimensional feature position encoding algorithm, which is based on a multi-dimensional Gaussian mixture model to position encode data of any length and size to be encoded, and the characteristics of the position encoding are symmetry, data-driven, network calculation parallelism and parameter validity. In short, considering the application prospects of the network attention mechanism in the field of highlighting processing, this embodiment has certain practical value and realistic significance.

[0070] This embodiment also provides an efficient pyramid network attention adjustment system for image processing, including a memory and a processor, wherein the memory stores a computer program, and the processor calls the computer program to execute the steps of the method described above.

[0071] The preferred specific embodiments of the present invention are described in detail above. It should be understood that a person skilled in the art can make many modifications and changes based on the concept of the present invention without creative work. Therefore, any technical solution that can be obtained by a person skilled in the art through logical analysis, reasoning or limited experiments based on the concept of the present invention on the basis of the prior art should be within the scope of protection determined by the claims.

Claims

1. A pyramid network attention adjustment method for image processing, used to adjust the size of the attention window during image processing, characterized in that: The method comprises the following steps: The deformable attention mechanism adjustment step is as follows: adjusting the range and size of the attention window based on a learnable position bias, wherein the learnable position bias is obtained by loading the image to be processed into a pre-built and trained neural network to obtain a position bias result; Attention pyramid network adjustment step: gradually dividing the size of the attention window according to the stage order of image processing; The calculation formula of the position offset is: In the formula, is the horizontal position offset of the attention window in the image, is the vertical position offset of the attention window in the image, Dense(·) is a fully connected network, Conv(·) is a convolutional neural network, W is the weight of the network, and f is the feature calculated by the previous layer of the network; The attention pyramid network adjustment step specifically includes: dividing the attention window into one or more pyramid modules; In the same stage of image processing, the attention window sizes between pyramid modules are multiples of each other; In different stages of image processing, the attention window sizes of corresponding pyramid modules are multiples of each other.

2. A pyramid network attention adjustment method for image processing according to claim 1, characterized in that: The deformable attention mechanism adjustment step also includes using an attention range truncation method to limit the size of the position bias.

3. A pyramid network attention adjustment method for image processing according to claim 2, characterized in that: The calculation expression of the attention range truncation method is: C((x,y),(h,w))=(max(min(x+h,h),1),max(min(y+w,w),1)) Where x is the vertical offset, y is the horizontal offset, h is the height of the image to be processed, w is the width of the image to be processed, max(·) is the maximum value, and min(·) is the minimum value.

4. The pyramid network attention adjustment method for image processing according to claim 1, characterized in that: The pyramid network attention adjustment method also includes: dividing the image to be processed into a plurality of block images, and performing the deformable attention mechanism adjustment step and the attention pyramid network adjustment step on each block image respectively.

5. A pyramid network attention adjustment method for image processing according to claim 4, characterized in that: The efficient pyramid network attention adjustment method also includes: High-dimensional feature position encoding step: use a Gaussian function to process the position of each block image, obtain a block image position code that satisfies the Gaussian function distribution, and perform image processing on the block image according to the block image position code.

6. A pyramid network attention adjustment method for image processing according to claim 5, characterized in that: The calculation expression for processing the position of each block image using the Gaussian function is: Where f(x) is the block image position code, x is the position of the block image, and a, b, and c are all real constants.

7. A pyramid network attention adjustment method for image processing according to claim 5, characterized in that: Image processing is performed on each block image through the attention window, and the position bias of the attention window is calculated through the deformable attention mechanism adjustment step. The size of the attention window is adjusted through the attention pyramid network adjustment step, and then the attention window of the next image processing stage is adjusted to perform image processing on each block image, and the output result is finally obtained by iterating in sequence.

8. An efficient pyramid network attention adjustment system for image processing, characterized in that: The method comprises a memory and a processor, wherein the memory stores a computer program, and the processor calls the computer program to execute the steps of any one of the methods according to claims 1 to 7.