Multi-scale attention mechanism method and module and image processing method and device
By introducing a multi-scale attention module in image processing and using grouped convolution layers and multiple scale branches to extract multi-scale feature maps, the problem of insufficient accuracy of the attention mechanism in the existing technology when processing multiple targets of different sizes is solved. Significantly improves the accuracy and precision of image processing.
Patent Information
- Application Number
- CN202210474867.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-29
- Publication Date
- 2024-09-13
- Estimated Expiration
- 2042-04-29
AI Technical Summary
The attention mechanism in the existing technology has poor accuracy when dealing with multiple targets of different sizes, and it is difficult to effectively capture multi-scale spatial relationships.
The multi-scale attention module is used to extract multi-scale feature maps through grouped convolution layers, multiple scale branches, addition units and matrix element-by-element multiplication operation units, providing rich scale spatial relationship information.
It improves the prediction accuracy when processing multiple targets of different sizes simultaneously, and improves the accuracy and precision of image processing.
Smart Images

Figure CN114897136B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a multi-scale attention mechanism method and module and an image processing method and device. Background Art
[0002] The human visual system can naturally and efficiently find important areas in complex scenes. Inspired by this phenomenon, the attention mechanism was introduced into the computer vision system. The attention mechanism has achieved great success in various computer vision tasks (such as image recognition, object detection, semantic segmentation, action recognition, image generation, 3D vision, etc.).
[0003] At present, deep attention networks in vision are usually based on the self-attention mechanism, which comes from natural language processing and is first used in machine translation tasks. The deep neural network built by the self-attention mechanism is called Transformer. In vision, Transformer first regards the image as a one-dimensional sequence, then models the image sequence through the stacked self-attention mechanism, and obtains the final processing result.
[0004] In addition to the Transformer structure based on self-attention, there are also some methods based on other attention mechanisms, such as large core attention, etc. However, the attention mechanism in the existing technology has poor accuracy in processing multiple objects of different sizes at the same time. Summary of the invention
[0005] The present invention provides a multi-scale attention mechanism method and module and an image processing method and device, so as to solve the defect of the attention mechanism in the prior art that the accuracy of simultaneously processing multiple objects of different sizes is poor, and improve the prediction accuracy when simultaneously processing multiple objects of different sizes.
[0006] In a first aspect, the present invention provides a multi-scale attention module, comprising: a grouped convolution layer, a plurality of scale branches, an addition unit, a common convolution layer, and a matrix element-by-element multiplication operation unit;
[0007] The grouped convolution layer is used to perform feature extraction on the feature map to be processed to obtain a first feature map;
[0008] Each of the scale branches is used to extract features from the first feature map to obtain a respective scale branch feature map;
[0009] The adding unit is used for adding the first feature map and the plurality of scale branch feature maps to obtain a second feature map;
[0010] The common convolution layer is used to extract features from the second feature map to obtain an attention map;
[0011] The matrix element-by-element multiplication operation unit is used to perform a matrix element-by-element multiplication operation on the attention map and the feature map to be processed to obtain a multi-scale feature map;
[0012] Among them, at least two of the multiple scale branches have different feature extraction scales.
[0013] Optionally, the scale branch includes a first convolution kernel and a second convolution kernel connected in series;
[0014] The dimension of the first convolution kernel is 1×k i ;
[0015] The dimension of the second convolution kernel is k i ×1;
[0016] Among them, i represents the i-th scale branch, k i is a positive integer, k i represents the dimension parameter of the scale branch, and i is a positive integer.
[0017] In a second aspect, the present invention provides a multi-scale attention mechanism method, comprising:
[0018] Perform feature extraction on the feature map to be processed to obtain a first feature map;
[0019] Performing feature extraction on the first feature map to obtain multiple scale branch feature maps;
[0020] Adding the first feature map and the multiple scale branch feature maps to obtain a second feature map;
[0021] Performing feature extraction on the second feature map to obtain an attention map;
[0022] Performing a matrix element-by-element multiplication operation on the attention map and the feature map to be processed to obtain a multi-scale feature map;
[0023] Among them, at least two of the multiple scale branch feature maps have different feature extraction scales.
[0024] In a third aspect, the present invention provides an image processing method, comprising:
[0025] Obtain image data to be processed;
[0026] Inputting the image data to be processed into an image processing model to obtain an image processing result;
[0027] In which, the image processing model is established based on the multi-scale attention module as described in the first aspect, and the image processing model is obtained after training based on image samples and identification labels corresponding to the image samples. The identification labels are predetermined based on the image samples and correspond one-to-one to the image samples.
[0028] Optionally, the image processing model includes a plurality of the multi-scale attention modules;
[0029] The step of inputting the image data to be processed into an image processing model to obtain an image processing result includes:
[0030] Extracting features from the image data to be processed to obtain a feature map to be processed;
[0031] Inputting the feature map to be processed into q multi-scale attention modules in sequence to obtain q multi-scale feature maps;
[0032] splicing p multi-scale feature maps among the q multi-scale feature maps to obtain a first overall feature map;
[0033] Performing feature extraction on the first overall feature map to obtain a global feature map;
[0034] Wherein, q is a positive integer, and p is a positive integer.
[0035] Optionally, the image processing model is trained by the following steps:
[0036] The image processing model is trained based on back propagation.
[0037] Optionally, the identification tag corresponding to the image sample includes any one of the following:
[0038] a classification label corresponding to the image sample;
[0039] a segmentation label corresponding to each pixel in the image sample;
[0040] A detection label corresponding to each object detection box in the image sample.
[0041] In a fourth aspect, the present invention further provides an image processing device, comprising:
[0042] An acquisition module, used for acquiring image data to be processed;
[0043] A processing module, used for inputting the image data to be processed into an image processing model to obtain an image processing result;
[0044] In which, the image processing model is established based on the multi-scale attention module as described in the first aspect, and the image processing model is obtained after training based on image samples and identification labels corresponding to the image samples. The identification labels are predetermined based on the image samples and correspond one-to-one to the image samples.
[0045] In a fifth aspect, the present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the multi-scale attention mechanism method as described in the second aspect or the image processing method as described in the third aspect is implemented.
[0046] In a sixth aspect, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the multi-scale attention mechanism method as described in the second aspect or the image processing method as described in the third aspect.
[0047] The multi-scale attention mechanism method and module and the image processing method and device provided by the present invention extract multi-scale feature maps through a multi-scale attention module containing multiple scale branches. The multi-scale feature maps can provide rich scale-space relationship information, improve the prediction accuracy when processing multiple targets of different sizes simultaneously, and thus improve the accuracy and precision of image processing. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0049] Figure 1 is a schematic diagram of the structure of a multi-scale attention module provided by an embodiment of the present invention;
[0050] Figure 2 is a schematic diagram of the structure of a scale branch provided by an embodiment of the present invention;
[0051] Figure 3 is a flowchart of a multi-scale attention mechanism method provided by an embodiment of the present invention;
[0052] Figure 4 is a flowchart of an image processing method provided by an embodiment of the present invention;
[0053] Figure 5 is a structural schematic diagram of an image processing model provided by an embodiment of the present invention;
[0054] Figure 6 is a structural schematic diagram of an image processing device provided by an embodiment of the present invention;
[0055] Figure 7 It is a schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0056] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. 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.
[0057] The following is an introduction to the technical terms involved in the present invention:
[0058] Computer Vision (CV): It is the science of how to make machines "see" in the various research directions of Artificial Intelligence (AI). To be more specific, it refers to the use of cameras and computers to replace human eyes to identify, track and measure targets, and further process graphics so that the computer processes the images into images that are more suitable for human observation or transmission to instruments for detection. Computer vision technology usually includes image processing, image recognition, image semantic understanding, image retrieval, optical character recognition (OCR), video processing, video semantic understanding, video content / behavior recognition, three-dimensional object reconstruction, 3D technology, virtual reality, augmented reality, simultaneous positioning and map construction, and also includes biometric recognition technologies such as face recognition and fingerprint recognition.
[0059] Attention: This is a very common fact that is often overlooked. For example, when a bird flies across the sky, people often follow the bird, and the sky naturally becomes background information in the human visual system. The basic idea of the attention mechanism in computer vision is to let the system learn to focus on the areas of interest, ignore background information and focus on key information.
[0060] Combine the following Figure 1-Figure 2 Describe the multi-scale attention module provided by an embodiment of the present invention.
[0061] Figure 1 is a schematic diagram of the structure of the multi-scale attention module provided by an embodiment of the present invention. Figure 1As shown, the multi-scale attention module provided by the embodiment of the present invention includes: a grouped convolution layer 110, a plurality of scale branches 120, an addition unit 130, a common convolution layer 140 and a matrix element-by-element multiplication operation unit 150;
[0062] The grouped convolution layer 110 is used to extract features from the feature map to be processed to obtain a first feature map;
[0063] Each of the scale branches 120 is used to extract features from the first feature map to obtain a respective scale branch feature map;
[0064] The adding unit 130 is used for adding the first feature map and the plurality of scale branch feature maps to obtain a second feature map;
[0065] The common convolution layer 140 is used to extract features from the second feature map to obtain an attention map;
[0066] The matrix element-by-element multiplication operation unit 150 is used to perform a matrix element-by-element multiplication operation on the attention map and the feature map to be processed to obtain a multi-scale feature map;
[0067] Among them, at least two of the multiple scale branches have different feature extraction scales.
[0068] Specifically, the scale branch 120 can be a cross-crise convolution (also called a cross convolution kernel or a cross attention module, etc.); the addition unit 130 can be used to implement the addition operation; the ordinary convolution layer 140 is a 1×1 ordinary convolution. The grouped convolution layer 110 and the scale branch 120 are used to capture multi-scale spatial relationships; the ordinary convolution layer 140 is used to capture the relationship between channels; the matrix element-by-element multiplication operation unit 150 is used to implement the attention mechanism. The input of the multi-scale attention module can be the feature map F∈R C×H×W , where C represents the number of channels, H represents the height of the feature map, and W represents the width of the feature map.
[0069] The multi-scale attention module provided in the embodiment of the present invention extracts a multi-scale feature map through a multi-scale attention module including multiple scale branches. The multi-scale feature map can provide rich scale-space relationship information. The scale-space relationship information can represent the spatial relationship between objects in the image data. The multi-scale features can optimize target positioning and classification performance, thereby improving the prediction accuracy of the attention module when processing multiple targets of different sizes simultaneously, thereby improving the accuracy and precision of image processing.
[0070] Optionally, Figure 2 is a schematic diagram of the structure of the scale branch provided by an embodiment of the present invention, such as Figure 2As shown, the scale branch includes a first convolution kernel and a second convolution kernel connected in series;
[0071] The dimension of the first convolution kernel is 1×k i ;
[0072] The dimension of the second convolution kernel is k i ×1;
[0073] Among them, i represents the i-th scale branch, k i represents the dimension parameter of the scale branch, k i is a positive integer, and i is a positive integer.
[0074] Specifically, the first convolution kernel and the second convolution kernel may be grouped convolution kernels. It should be understood that the k of each scale branch i For example, a multi-scale attention module contains three scale branches, and the k i is 4, and the k of scale branch 2 i is 7, k of scale branch 3 i is 9, and the dimensions of the three scale branches are completely different.
[0075] The output of the multi-scale attention module is:
[0076]
[0077]
[0078] Among them, Output represents the output of the multi-scale attention module, F represents the feature map to be processed, Conv 1×1 Represents a 1×1 ordinary convolution, Scale i represents the i-th scale branch, j represents the total number of scale branches, and DW-Conv represents grouped convolution.
[0079] The multi-scale attention module provided by the embodiment of the present invention obtains a multi-scale feature map through scale branches of multiple different dimensions. The multi-scale feature map can provide rich scale-space relationship information. The scale-space relationship information can represent the spatial relationship between objects in the image data. The multi-scale features can optimize target positioning and classification performance, thereby improving the prediction accuracy of the attention module when processing multiple targets of different sizes simultaneously, thereby improving the accuracy and precision of image processing.
[0080] Combine the following Figure 3 Describe the multi-scale attention mechanism method provided by an embodiment of the present invention.
[0081] Figure 3 is a flow chart of the multi-scale attention mechanism method provided by an embodiment of the present invention, such as Figure 3 As shown, the multi-scale attention mechanism method provided by the embodiment of the present invention includes:
[0082] Step 310, performing feature extraction on the feature map to be processed to obtain a first feature map;
[0083] Step 320, performing feature extraction on the first feature map to obtain multiple scale branch feature maps;
[0084] Step 330, adding the first feature map and the multiple scale branch feature maps to obtain a second feature map;
[0085] Step 340, extracting features from the second feature map to obtain an attention map;
[0086] Step 350, performing a matrix element-by-element multiplication operation on the attention map and the feature map to be processed to obtain a multi-scale feature map;
[0087] Among them, at least two of the multiple scale branch feature maps have different feature extraction scales.
[0088] The multi-scale attention mechanism method provided by the embodiment of the present invention extracts a multi-scale feature map through a multi-scale attention module including multiple scale branches. The multi-scale feature map can provide rich scale-space relationship information. The scale-space relationship information can represent the spatial relationship between objects in the image data. The multi-scale features can optimize target positioning and classification performance, thereby improving the prediction accuracy of the attention module when processing multiple targets of different sizes simultaneously, thereby improving the accuracy and precision of image processing.
[0089] It should be noted here that the above method provided by the embodiment of the present invention corresponds to the function implemented by the above device embodiment and can achieve the same technical effect. The parts and beneficial effects of this embodiment that are the same as those of the method embodiment will not be described in detail here.
[0090] Combine the following Figure 4 Describe the multi-scale attention mechanism method provided by an embodiment of the present invention.
[0091] Figure 4 is a flow chart of an image processing method provided by an embodiment of the present invention, such as Figure 4 As shown, the image processing method provided by the embodiment of the present invention includes:
[0092] Step 410, obtaining image data to be processed;
[0093] Specifically, the image data to be processed is image data that needs to be processed. The image data to be processed may be taken by a camera, acquired by other image acquisition devices, or obtained through a database. The embodiment of the present invention does not specifically limit the method for acquiring the image to be processed, and it is sufficient to accurately acquire the image to be processed.
[0094] Step 420, inputting the image data to be processed into an image processing model to obtain an image processing result;
[0095] Among them, the image processing model is established based on the above-mentioned multi-scale attention module, and the image processing model is obtained after training based on image samples and identification labels corresponding to the image samples. The identification labels are predetermined based on the image samples and correspond one-to-one to the image samples.
[0096] It should be understood that the image processing model provided by the embodiment of the present invention may include one or more multi-scale attention modules provided by the embodiment of the present invention. In addition to the multi-scale attention module, building an image processing model (i.e., a neural network) still relies on other neural network components such as a multi-layer perceptron, a convolutional layer, a normalization layer, a fully connected layer, and a nonlinear activation layer. With the above layers, a complete neural network is successfully built, and the image is specifically processed based on the built neural network. Exemplarily, the image processing process may include: extracting features from image data to obtain image data features, so that the trained image data processing model can process the image data features. It should be understood that the multi-scale attention module can be used to process image data with a two-dimensional structure. Since the image processing model is constructed based on the multi-scale attention module, it is equivalent to the image processing model being trained based on a multi-scale attention network that can directly process two-dimensional image structures.
[0097] Optionally, the identification tag corresponding to the image sample includes any one of the following:
[0098] a classification label corresponding to the image sample;
[0099] a segmentation label corresponding to each pixel in the image sample;
[0100] A detection label corresponding to each object detection box in the image sample.
[0101] Specifically, the classification label corresponding to the image sample can be obtained in the following manner:
[0102] Obtain image samples, and mark each image sample with a classification label to construct a first training sample set;
[0103] The image processing model is trained based on the first training sample set to obtain an image classification model (that is, the image processing model can realize an image classification function).
[0104] Specifically, the segmentation label corresponding to each pixel in the image sample can be obtained as follows:
[0105] Obtain image samples, and mark a segmentation label for each pixel in each image sample to construct a second training sample set;
[0106] The image processing model is trained based on the second training sample set to obtain an image segmentation model (that is, the image processing model can realize the image segmentation function).
[0107] Specifically, the detection label corresponding to each object detection frame in the image sample can be obtained in the following manner:
[0108] Obtain image samples, and label each object detection frame in each image sample to construct a third training sample set;
[0109] The image processing model is trained based on the third training sample set to obtain an image detection model (ie, the image processing model can implement an image detection function).
[0110] The image processing method provided by the embodiment of the present invention obtains the image data to be processed and directly inputs it into the image processing model for data processing, thereby obtaining the corresponding processing result. The function and processing result of the image processing model can be determined according to the image sample and the identification label corresponding to the image sample, and has strong adaptability to the diversity of image processing tasks.
[0111] Optionally, Figure 5 is a schematic diagram of the structure of the image processing model provided by the embodiment of the present invention, such as Figure 5 As shown, the image processing model provided by the embodiment of the present invention may include: multiple downsampling modules, multiple multi-scale attention modules, a splicing module and a global module.
[0112] It should be understood that Figure 5 Just to facilitate understanding of the examples of the present invention, the image processing model may include any number of downsampling modules, or may not include any downsampling modules; the number of multi-scale attention modules in the image processing model may be any positive integer; the image processing model may also include other commonly used components of neural networks.
[0113] Optionally, the image processing model includes a plurality of the multi-scale attention modules;
[0114] The step of inputting the image data to be processed into an image processing model to obtain an image processing result includes:
[0115] Step 421, extracting features from the image data to be processed to obtain a feature map to be processed;
[0116] Specifically, feature extraction of the image data to be processed can be achieved through a feature extraction module, and feature extraction of the image data to be processed can be performed through a neural network component, so as to utilize the extracted features to input an image processing model for image processing, and the neural network component includes at least one of a multi-layer perceptron, a convolutional layer, and a normalization layer.
[0117] Step 422, inputting the feature map to be processed into q multi-scale attention modules in sequence to obtain q multi-scale feature maps;
[0118] Step 423, concatenating p of the q multi-scale feature maps to obtain a first overall feature map;
[0119] Step 424, performing feature extraction on the first overall feature map to obtain a global feature map;
[0120] Wherein, q is a positive integer, and p is a positive integer.
[0121] Specifically, feature extraction may be performed on the first overall feature map through a Global Head module, and the global feature map may provide a global receptive field, that is, provide global information.
[0122] It should be understood that all q feature maps can be spliced, and the multi-scale feature information in the first overall feature map is richer; splicing p (p is less than q) feature maps among the q feature maps can reduce the amount of calculation. Optionally, when splicing p (p is less than q) feature maps among the q feature maps, the (qp)th feature map to the qth feature map can be spliced.
[0123] Optionally, the image processing model is trained by the following steps:
[0124] The image processing model is trained based on back propagation.
[0125] Specifically, based on the back propagation algorithm, the image processing model is optimized to obtain an optimized image processing model, and the image data is processed by the optimized image data processing model.
[0126] The image processing algorithm provided by the embodiment of the present invention trains the image processing model based on back propagation. The basic idea of the BP (back propagation) algorithm is to first assign initial weights and thresholds to the network, calculate the output value of the network through inter-layer forward information transmission, and then modify the weights and thresholds of the network according to the error between the actual output and the expected output, and minimize the simulation error of the algorithm through repeated training and comparison. The BP neural network has the advantages of nonlinear mapping ability, self-learning and self-adaptation ability, generalization ability, fault tolerance, etc. Through the back propagation algorithm, the image processing model is optimized and the optimized weights are returned; then, the image data is processed through the image processing model using the optimized weights, so as to obtain more accurate image data processing results.
[0127] Combine the following Figure 6 An image processing device provided by an embodiment of the present invention is described.
[0128] Figure 6 is a schematic diagram of the structure of an image processing device provided by an embodiment of the present invention, such as Figure 6 As shown, the image processing device provided by the embodiment of the present invention includes an acquisition module 610 and a processing module 620:
[0129] An acquisition module 610 is used to acquire image data to be processed;
[0130] The processing module 620 is used to input the image data to be processed into the image processing model to obtain an image processing result;
[0131] The image processing model is based on Figure 1 The multi-scale attention module is established, and the image processing model is obtained after training based on image samples and identification labels corresponding to the image samples. The identification labels are predetermined based on the image samples and correspond one-to-one to the image samples.
[0132] It should be noted here that the above-mentioned device provided in the embodiment of the present invention can implement all the method steps implemented in the above-mentioned method embodiment, and can achieve the same technical effect. The parts and beneficial effects that are the same as the method embodiment in this embodiment will not be described in detail here.
[0133] Figure 7 An example of a physical structure diagram of an electronic device is shown in FIG. Figure 7As shown, the electronic device may include: a processor 710, a communication interface 720, a memory 730 and a communication bus 740, wherein the processor 710, the communication interface 720 and the memory 730 communicate with each other through the communication bus 740. The processor 710 may call the logic instructions in the memory 730 to execute the multi-scale attention mechanism method or the image processing method. The multi-scale attention mechanism method includes: performing feature extraction on the feature map to be processed to obtain a first feature map; performing feature extraction on the first feature map to obtain multiple scale branch feature maps; adding the first feature map and the multiple scale branch feature maps to obtain a second feature map; performing feature extraction on the second feature map to obtain an attention map; performing a matrix element-by-element multiplication operation on the attention map and the feature map to be processed to obtain a multi-scale feature map; wherein the feature extraction scales of at least two of the scale branch feature maps in the multiple scale branch feature maps are different. The image processing method comprises: obtaining image data to be processed; inputting the image data to be processed into an image processing model to obtain an image processing result; wherein the image processing model is based on Figure 1 The attention module is established, and the image processing model is obtained after training based on image samples and identification labels corresponding to the image samples. The identification labels are predetermined based on the image samples and correspond one-to-one with the image samples.
[0134] In addition, the logic instructions in the above-mentioned memory 730 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.
[0135] On the other hand, the present invention also provides a computer program product, which includes a computer program. The computer program can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the above-mentioned methods to perform a multi-scale attention mechanism method or an image processing method. The multi-scale attention mechanism method includes: performing feature extraction on the feature map to be processed to obtain a first feature map; performing feature extraction on the first feature map to obtain multiple scale branch feature maps; adding the first feature map and the multiple scale branch feature maps to obtain a second feature map; performing feature extraction on the second feature map to obtain an attention map; performing matrix element-by-element multiplication operation on the attention map and the feature map to be processed to obtain a multi-scale feature map; wherein, the feature extraction scales of at least two of the scale branch feature maps in the multiple scale branch feature maps are different. The image processing method includes: obtaining image data to be processed; inputting the image data to be processed into an image processing model to obtain an image processing result; wherein, the image processing model is based on the following: Figure 1 The attention module is established, and the image processing model is obtained after training based on image samples and identification labels corresponding to the image samples. The identification labels are predetermined based on the image samples and correspond one-to-one with the image samples.
[0136] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, is implemented to execute the above-mentioned methods to execute a multi-scale attention mechanism method or an image processing method. The multi-scale attention mechanism method includes: performing feature extraction on a feature map to be processed to obtain a first feature map; performing feature extraction on the first feature map to obtain multiple scale branch feature maps; adding the first feature map and the multiple scale branch feature maps to obtain a second feature map; performing feature extraction on the second feature map to obtain an attention map; performing a matrix element-by-element multiplication operation on the attention map and the feature map to be processed to obtain a multi-scale feature map; wherein, at least two of the scale branch feature maps in the multiple scale branch feature maps have different feature extraction scales. The image processing method includes: obtaining image data to be processed; inputting the image data to be processed into an image processing model to obtain an image processing result; wherein, the image processing model is based on the following: Figure 1 The multi-scale attention module is established, and the image processing model is obtained after training based on image samples and identification labels corresponding to the image samples. The identification labels are predetermined based on the image samples and correspond one-to-one to the image samples.
[0137] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.
[0138] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0139] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. An image processing method, characterized in that: include: Obtain image data to be processed; Inputting the image data to be processed into an image processing model to obtain an image processing result; The image processing model is established based on a multi-scale attention module, and the image processing model is obtained after training based on image samples and identification labels corresponding to the image samples, and the identification labels are predetermined according to the image samples and correspond one-to-one to the image samples; The multi-scale attention module includes: a grouped convolution layer, multiple scale branches, an addition unit, a common convolution layer and a matrix element-by-element multiplication operation unit; The grouped convolution layer is used to perform feature extraction on the feature map to be processed to obtain a first feature map; Each of the scale branches is used to extract features from the first feature map to obtain a respective scale branch feature map; The adding unit is used for adding the first feature map and the plurality of scale branch feature maps to obtain a second feature map; The common convolution layer is used to extract features from the second feature map to obtain an attention map; The matrix element-by-element multiplication operation unit is used to perform a matrix element-by-element multiplication operation on the attention map and the feature map to be processed to obtain a multi-scale feature map; Among them, at least two of the multiple scale branches have different feature extraction scales.
2. The image processing method according to claim 1, characterized in that: The scale branch includes a first convolution kernel and a second convolution kernel connected in series; The dimension of the first convolution kernel is: The dimension of the second convolution kernel is: Wherein, i represents the i-th scale branch, is a positive integer, represents the dimension parameter of the scale branch, and i is a positive integer.
3. The image processing method according to claim 1, characterized in that: The image processing model includes a plurality of the multi-scale attention modules; The step of inputting the image data to be processed into an image processing model to obtain an image processing result includes: Extracting features from the image data to be processed to obtain a feature map to be processed; Inputting the feature map to be processed into q multi-scale attention modules in sequence to obtain q multi-scale feature maps; splicing p multi-scale feature maps among the q multi-scale feature maps to obtain a first overall feature map; Performing feature extraction on the first overall feature map to obtain a global feature map; Wherein, q is a positive integer, and p is a positive integer.
4. The image processing method according to claim 1, characterized in that: The image processing model is trained by the following steps: The image processing model is trained based on back propagation.
5. The image processing method according to claim 1, characterized in that: The identification label corresponding to the image sample includes any of the following: a classification label corresponding to the image sample; a segmentation label corresponding to each pixel in the image sample; A detection label corresponding to each object detection box in the image sample.
6. An image processing device, characterized in that: include: An acquisition module, used for acquiring image data to be processed; A processing module, used for inputting the image data to be processed into an image processing model to obtain an image processing result; The image processing model is established based on a multi-scale attention module, and the image processing model is obtained after training based on image samples and identification labels corresponding to the image samples, and the identification labels are predetermined according to the image samples and correspond one-to-one to the image samples; The multi-scale attention module includes: a grouped convolution layer, multiple scale branches, an addition unit, a common convolution layer and a matrix element-by-element multiplication operation unit; The grouped convolution layer is used to perform feature extraction on the feature map to be processed to obtain a first feature map; Each of the scale branches is used to extract features from the first feature map to obtain a respective scale branch feature map; The adding unit is used for adding the first feature map and the plurality of scale branch feature maps to obtain a second feature map; The common convolution layer is used to extract features from the second feature map to obtain an attention map; The matrix element-by-element multiplication operation unit is used to perform a matrix element-by-element multiplication operation on the attention map and the feature map to be processed to obtain a multi-scale feature map; Among them, at least two of the multiple scale branches have different feature extraction scales.
7. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the program, the image processing method according to any one of claims 1 to 5 is implemented.
8. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the image processing method according to any one of claims 1 to 5 is implemented.
