Image recognition method, device, electronic device and storage medium
By performing feature extraction and orthogonal compression on images, generating attention maps and performing fusion processing, the problem of low recognition accuracy of small target objects in image recognition is solved and the recognition accuracy is significantly improved.
Patent Information
- Application Number
- CN202410578289.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-11
- Publication Date
- 2024-08-27
- Estimated Expiration
- 2044-05-11
AI Technical Summary
In image recognition, especially for small target objects, the existing technology has the problem of low accuracy, because the characteristics of small target objects are relatively unobvious, resulting in redundant information interference and feature information flooding during the recognition process, affecting the recognition accuracy. .
By performing feature extraction processing on the image to be recognized, a multi-layer input feature map is generated, and each layer of feature maps is orthogonally compressed to generate an attention map. The attention map is then fused to remove redundant information and highlight the features of the identified object. features to improve recognition accuracy. Specific steps include determining the orthogonal relationship of feature vectors, generating attention maps through residual connections, determining the number of objects to be selected through block statistics and pooling processing, and performing a second fusion process to generate the final target recognition result.
It effectively removes redundant information in the input feature map, highlights the characteristics of the identified objects, and significantly improves the accuracy of image recognition, especially the ability to identify small target objects.
Smart Images

Figure CN118154892B
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence technology, and in particular to an image recognition method, device, electronic device and storage medium. Background Art
[0002] In the application scenario of image recognition, the recognition object contained in the image is identified from the image to be recognized according to the preset recognition object. The recognition object includes but is not limited to: vehicles, buildings, or plants, etc.
[0003] In the related art, an image to be identified is acquired by photographing or other means, and a preset identification object is identified from the image to be identified.
[0004] In practical applications, the objects to be identified include small objects that occupy a small pixel range and large objects that occupy a large pixel range. Since the features of small objects are relatively inconspicuous, there is a problem of low accuracy in identifying small objects. Summary of the invention
[0005] The present application provides an image recognition method, device, electronic device and storage medium to improve the accuracy of image recognition.
[0006] In a first aspect, the present application provides an image recognition method, comprising: receiving an object recognition request, the object recognition request comprising an image to be recognized; performing feature extraction processing on the image to be recognized according to a plurality of preset extraction depths to obtain a multi-layer input feature map corresponding to the image to be recognized, the plurality of extraction depths and the multi-layer input feature map Figure 1 One to one; for any layer of input feature map, the input feature map is subjected to orthogonal compression processing to obtain the attention map corresponding to the input feature map; each layer of attention map is subjected to a first fusion processing to obtain the target recognition result corresponding to the image to be recognized, and the target recognition result includes multiple target objects.
[0007] In a possible implementation, the input feature map is subjected to orthogonal compression processing to obtain an attention map corresponding to the input feature map, including: determining multiple feature vectors of multiple dimensions of the input feature map, the multiple feature vectors are orthogonal to each other, the multiple dimensions include at least a channel dimension, a high dimension, or a wide dimension, and the multiple dimensions correspond one-to-one to the multiple feature vectors; and superimposing each feature vector on the input feature map by residual connection to obtain the attention map corresponding to the input feature map.
[0008] In a possible implementation, a first fusion process is performed on each layer of the attention map to obtain a target recognition result corresponding to the image to be recognized, including: determining an output feature map corresponding to each layer of the attention map; and performing a first fusion process on the output feature map to obtain the target recognition result.
[0009] In one possible implementation, determining the output feature map corresponding to each layer of the attention map includes: determining the number of objects to be selected in each layer of the attention map by a block statistical method; performing pooling processing and a second fusion processing on each layer of the attention map according to the number of objects to be selected in each layer of the attention map, to obtain the output feature map corresponding to each layer of the attention map.
[0010] In a possible implementation, the number of objects to be selected in each layer of the attention map is determined by a block statistics method, including: for any layer of the attention map, determining the number of layers corresponding to the attention map, and determining the number of blocks according to the number of layers corresponding to the attention map; performing block processing on the attention map according to the number of blocks to obtain multiple feature blocks; determining a response value of each feature block; and determining the number of objects to be selected in each layer of the attention map according to the response value of each feature block of each layer of the attention map.
[0011] In a possible implementation, the number of objects to be selected in each layer of the attention map is determined according to the response value of each feature block of each layer of the attention map, including: for any feature block of each layer of the attention map, if the response value is less than or equal to a first threshold, the number of objects to be selected in the feature block is determined to be 0; if the response value is greater than a second threshold, the number of objects to be selected in the feature block is determined to be 1; if the response value is greater than the first threshold and less than or equal to the second threshold, the number of objects to be selected in the feature block is determined according to the product of the response value and the first numerical value; according to the number of objects to be selected in each feature block of each layer of the attention map, the number of objects to be selected in each layer of the attention map is determined.
[0012] In a possible implementation, according to the number of objects to be selected in each layer of the attention map, each layer of the attention map is pooled and subjected to a second fusion process to obtain an output feature map corresponding to each layer of the attention map, including: according to the response value of each feature block of each layer of the attention map, each layer of the attention map is pooled to obtain a pooling result of each layer of the attention map, and the pooling process includes average pooling or maximum pooling; for any layer of the attention map, a weight is determined according to the number of objects to be selected in the attention map and the number of objects to be selected in an adjacent upper layer of the attention map; according to the weight, a second fusion process is performed on the pooling result of the attention map and the pooling result of the adjacent upper layer of the attention map to obtain an output feature map corresponding to the attention map.
[0013] In a second aspect, the present application provides an image recognition device, comprising: a receiving module, configured to receive an object recognition request, wherein the object recognition request includes an image to be recognized; an extraction module, configured to perform feature extraction processing on the image to be recognized according to a plurality of preset extraction depths, to obtain a multi-layer input feature map corresponding to the image to be recognized, wherein the plurality of extraction depths are correlated with the multi-layer input feature map; Figure 1 One-to-one correspondence; a compression module, used to perform orthogonal compression processing on the input feature map of any layer to obtain the attention map corresponding to the input feature map; a fusion module, used to perform a first fusion processing on each layer of the attention map to obtain the target recognition result corresponding to the image to be recognized, and the target recognition result includes multiple target objects.
[0014] In a possible implementation, the compression module is specifically used to determine multiple feature vectors of multiple dimensions of the input feature map, the multiple feature vectors are orthogonal to each other, the multiple dimensions include at least channel dimension, high dimension, or wide dimension, and the multiple dimensions correspond one-to-one to the multiple feature vectors; the compression module is also specifically used to superimpose each feature vector on the input feature map by residual connection to obtain an attention map corresponding to the input feature map.
[0015] In a possible implementation, the device further includes: a processing module, used to determine an output feature map corresponding to each layer of the attention map; the processing module is also used to perform a first fusion processing on the output feature map to obtain the target recognition result.
[0016] In a possible implementation, the processing module is specifically used to determine multiple candidate objects for each layer of the attention map by a block statistical method; the processing module is also specifically used to perform pooling processing and a second fusion processing on each layer of the attention map according to the number of candidate objects for each layer of the attention map, so as to obtain an output feature map corresponding to each layer of the attention map.
[0017] In a possible implementation, the processing module is specifically used to determine, for any layer of the attention map, the number of layers corresponding to the attention map, and determine the number of blocks according to the number of layers corresponding to the attention map; the processing module is also specifically used to perform block processing on the attention map according to the number of blocks to obtain multiple feature blocks; the processing module is also specifically used to determine the response value of each feature block; the processing module is also specifically used to determine the number of objects to be selected for each layer of the attention map according to the response value of each feature block of each layer of the attention map.
[0018] In a possible implementation, the processing module is specifically used to, for any one of the feature blocks of each layer of the attention map, determine that the number of candidates for selection of the feature block is 0 if the response value is less than or equal to a first threshold; the processing module is also specifically used to determine that the number of candidates for selection of the feature block is 1 if the response value is greater than a second threshold; the processing module is also specifically used to determine the number of candidates for selection of the feature block according to the product of the response value and a first numerical value if the response value is greater than the first threshold and less than or equal to the second threshold; the processing module is also specifically used to determine the number of candidates for selection of each layer of the attention map according to the number of candidates for selection of each feature block of each layer of the attention map.
[0019] In a possible embodiment, the device also includes: an execution module, which is used to perform pooling processing on each layer of attention maps according to the response value of each feature block of each layer of attention maps to obtain a pooling result of each layer of attention maps, and the pooling processing includes average pooling processing or maximum pooling processing; the execution module is also used to determine the weight for any layer of attention maps according to multiple candidate objects of the attention map and multiple candidate objects of an adjacent upper layer attention map of the attention map; the execution module is also used to perform a second fusion processing on the pooling result of the attention map and the pooling result of the adjacent upper layer attention map of the attention map according to the weight to obtain an output feature map corresponding to the attention map.
[0020] In a third aspect, the present application provides an electronic device comprising: a processor, and a memory communicatively connected to the processor; the memory stores computer-executable instructions; the processor executes the computer-executable instructions stored in the memory to implement any method described in the first aspect.
[0021] In a fourth aspect, the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions, and the computer-executable instructions are executed by a processor as described in any one of the methods in the first aspect.
[0022] The image recognition method, device, electronic device and storage medium provided by the present application include: receiving an object recognition request, wherein the object recognition request includes an image to be recognized; performing feature extraction processing on the image to be recognized according to a plurality of preset extraction depths, obtaining a multi-layer input feature map corresponding to the image to be recognized, wherein the plurality of extraction depths are correlated with the multi-layer input feature map; Figure 1One-to-one correspondence; for any layer of input feature map, the input feature map is subjected to orthogonal compression processing to obtain the attention map corresponding to the input feature map; each layer of attention map is subjected to a first fusion processing to obtain the target recognition result corresponding to the image to be recognized, and the target recognition result includes multiple target objects. The above scheme can remove redundant information in the input feature map by performing orthogonal compression processing on the input feature map, highlight the features related to the recognition object, and thus improve the accuracy of image recognition. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0024] Figure 1 A schematic diagram of an application scenario of an image recognition method provided in an embodiment of the present application;
[0025] Figure 2 A flowchart of an image recognition method provided in an embodiment of the present application;
[0026] Figure 3 A schematic diagram of a multi-layer input feature map provided in an embodiment of the present application;
[0027] Figure 4 A flowchart of an image recognition method provided in an embodiment of the present application;
[0028] Figure 5 A schematic diagram of determining a feature vector provided in an embodiment of the present application;
[0029] Figure 6 A schematic diagram of a second fusion process provided in an embodiment of the present application;
[0030] Figure 7 A schematic diagram of the structure of an image recognition device provided in an embodiment of the present application;
[0031] Figure 8 A schematic diagram of the structure of an image recognition device provided in an embodiment of the present application;
[0032] Fig. 9 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application.
[0033] The above drawings have shown clear embodiments of the present application, which will be described in more detail later. These drawings and text descriptions are not intended to limit the scope of the present application in any way, but to illustrate the concept of the present application to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION
[0034] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.
[0035] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use, processing, transmission, provision, disclosure and application of the relevant data comply with the relevant laws, regulations and standards of the relevant countries and regions, take necessary confidentiality measures, do not violate public order and good customs, and provide corresponding operation entrances for users to choose to authorize or refuse.
[0036] It should be noted that the image recognition method, device, electronic device and storage medium of the present application can be used in the field of artificial intelligence technology, and can also be used in any field other than artificial intelligence. The application field of the image recognition method, device, electronic device and storage medium of the present application is not limited.
[0037] Figure 1 A schematic diagram of an application scenario of an image recognition method provided in an embodiment of the present application is given as an example in combination with the illustrated scenario: receiving an image to be recognized, the image to be recognized includes multiple objects to be selected, recognizing the image to be recognized, and determining multiple objects in the image to be recognized.
[0038] In the related art, the network model is used to identify the image to be identified and the identified object is obtained. For small target objects, since small target objects occupy a small number of pixels, their feature information will gradually be submerged in the convolution and pooling process, and there will be omissions in the recognition process, resulting in low recognition accuracy.
[0039] The data transmission method provided in this application is intended to solve the above technical problems in the prior art.
[0040] The technical solution of the present application and how the technical solution of the present application solves the above-mentioned technical problems are described in detail below with specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present application will be described below in conjunction with the accompanying drawings.
[0041] Figure 2 A schematic diagram of a flow chart of an image recognition method provided in an embodiment of the present application, the method comprising the following steps:
[0042] S201: Receive an object recognition request, where the object recognition request includes an image to be recognized.
[0043] As an example, the execution subject of this embodiment may be an image recognition device, and there are many ways to implement the image recognition device. For example, it may be program software, or a medium storing relevant computer programs, such as a USB flash drive, etc.; or, the device may also be a physical device integrated or installed with relevant computer programs, such as a chip, a smart terminal, a computer, a server, etc.
[0044] The image to be identified includes a plurality of objects to be selected, and the objects to be selected are objects to be identified.
[0045] Optionally, the object identification request includes the type of the object to be selected.
[0046] Combined with the scene example, the image to be identified may include multiple types of objects, including but not limited to vehicles, buildings, or plants. The object recognition request includes the type of the object to be selected, and the identification can be performed on this type to avoid other types of objects interfering with the recognition results, thereby improving the recognition accuracy.
[0047] S202, according to the preset multiple extraction depths, feature extraction processing is performed on the image to be identified to obtain a multi-layer input feature map corresponding to the image to be identified, and the multiple extraction depths and the multi-layer input feature map are Figure 1 One to one correspondence.
[0048] Optionally, feature extraction is performed on the image to be identified through a Feature Pyramid Network (FPN).
[0049] Among them, the feature pyramid network is a deep learning model structure. The feature pyramid network first extracts the features of the image to be identified through the backbone network and extracts the feature map at a specific depth as a layer in the feature pyramid. When constructing the feature pyramid, the output of each structural block of the backbone network is generally extracted. The depth difference between the selected feature maps is uniform and normalized. The feature quality is high and stable. The height and width of each layer of feature maps are half of the lower layer of feature maps. The multi-scale and multi-level feature structure can effectively solve the problem of target scale diversity.
[0050] Next, combine Figure 3 Explain the multiple layers of input feature maps.
[0051] Figure 3 Schematic diagram of a multi-layer input feature map provided in an embodiment of the present application. Figure 3As shown, feature maps are extracted from the image to be identified according to different depths to obtain C2 input feature maps, C3 input feature maps and C4 input feature maps. Each input feature map corresponds to a different layer, and each input feature map corresponds to a different extraction depth.
[0052] S203. For any layer of input feature map, perform orthogonal compression processing on the input feature map to obtain an attention map corresponding to the input feature map.
[0053] Among them, orthogonal compression processing includes orthogonal transformation processing and compression processing. Through orthogonal transformation processing, multiple orthogonal feature vectors of the input feature map are obtained. Through orthogonal transformation, independent information between different feature channels can be separated to reduce redundancy between channels. Through compression processing, the dimension of orthogonal feature vectors is reduced to strengthen the characteristics of independent information and reduce the interference of redundant information.
[0054] Optionally, the input feature map is input into an attention module based on orthogonal compression to generate a corresponding attention map. The attention module based on orthogonal compression includes multiple branches, each of which compresses the dimension corresponding to the input feature map, and acts on the input feature map in the form of a residual to adjust its weight, supplement it with information about small target objects in the channel and spatial dimensions, and obtain an attention map.
[0055] Combined with the scene example, compared with the direct recognition of the image to be recognized in the related art, the present application can enhance the characteristics of small target objects with less calculation during the orthogonal compression process, thereby improving the recognition accuracy of small target objects.
[0056] S204: Perform a first fusion process on each layer of the attention map to obtain a target recognition result corresponding to the image to be recognized, where the target recognition result includes multiple target objects.
[0057] Combined with the scene example, the pixel area occupied by small target objects is relatively small. It is easy to ignore its details when directly detecting it on the deep (strong semantics but low resolution) attention map, while detecting it on the shallow (high spatial resolution but weak semantics) attention map may lack sufficient semantic information for correct classification. Performing the first fusion processing on each layer of attention map can make the deeper features guide the shallow features, combine the rich semantic information of the deep features with the spatial details of the shallow features, and form a feature map across multiple scales, so as to fully characterize the small target objects and help capture the key features of the small target objects.
[0058] Optionally, a detection head without a preset anchor box is used to perform hierarchical detection on the fused features. Parameters can be shared across scales in the detection head, and the number of parameters can be reduced by merging different BN layers.
[0059] The image recognition method provided by the embodiment of the present application includes: receiving an object recognition request, the object recognition request includes an image to be recognized; performing feature extraction processing on the image to be recognized according to a plurality of preset extraction depths, obtaining a multi-layer input feature map corresponding to the image to be recognized, and the plurality of extraction depths and the multi-layer input feature map are combined to obtain a multi-layer input feature map corresponding to the image to be recognized; Figure 1 One-to-one correspondence; for any layer of input feature map, perform orthogonal compression processing on the input feature map to obtain the attention map corresponding to the input feature map; perform the first fusion processing on each layer of attention map to obtain the target recognition result corresponding to the image to be recognized, and the target recognition result includes multiple target objects. The above scheme can remove redundant information in the input feature map by performing orthogonal compression processing on the input feature map, highlight the features related to the recognition object, and thus improve the accuracy of image recognition.
[0060] Based on any of the above embodiments, Figure 4 , the detailed process of image recognition is explained.
[0061] Figure 4 The following is a flow chart of an image recognition method provided in an embodiment of the present application. Figure 4 As shown, the method includes:
[0062] S401: Receive an object recognition request, where the object recognition request includes an image to be recognized, and the image to be recognized includes a plurality of objects to be selected.
[0063] It should be noted that the execution process of S401 refers to S201 and will not be repeated here.
[0064] S402, according to the preset multiple extraction depths, feature extraction processing is performed on the image to be identified to obtain a multi-layer input feature map corresponding to the image to be identified, and the multiple extraction depths are combined with the multi-layer input feature map. Figure 1 One to one correspondence.
[0065] It should be noted that the execution process of S402 refers to S202 and will not be repeated here.
[0066] S403: Determine multiple feature vectors of multiple dimensions of the input feature map.
[0067] Among them, there is an orthogonal relationship between the multiple feature vectors, the multiple dimensions at least include a channel dimension, a high dimension, or a wide dimension, and the multiple dimensions correspond one-to-one to the multiple feature vectors.
[0068] Exemplarily, the input feature map is compressed according to a preset dimension to obtain multiple feature vectors of the preset dimension.
[0069] Combined with the scenario example, the key information of each feature vector is extracted through compression processing to obtain the compression processing result. The compression processing result removes redundant information, avoids the interference of redundant information on recognition, and thus improves recognition accuracy.
[0070] Next, combine Figure 5 Determination of eigenvectors will be described.
[0071] Figure 5 Schematic diagram of determining feature vectors provided in the embodiment of the present application. Figure 5 As shown, the feature vectors of three dimensions of the input feature map are determined, including the channel vector, the height vector and the width vector. The three feature vectors are orthogonal to each other.
[0072] S404. Superimpose each feature vector on the input feature map through residual connection to obtain an attention map corresponding to the input feature map.
[0073] Exemplarily, the formula for generating the attention map is:
[0074]
[0075] Among them, i is the number of layers, A i is the attention map, C i is the input feature map, is the feature vector of the input feature map channel dimension, is the feature vector of the input feature map height dimension, is the feature vector of the dimension of the input feature map width.
[0076] Based on the above implementation, by superimposing each feature vector on the input feature map, the input feature map can be weighted according to each feature vector to enhance the features of small target objects, thereby improving recognition accuracy. At the same time, the computational complexity of this method is relatively small, which can improve the efficiency of image recognition.
[0077] S405: Determine the number of objects to be selected in each layer of the attention map by block statistics.
[0078] Optionally, the scale of the blocks of each attention map is determined according to the number of layers of the attention map.
[0079] Combined with the scene example, in the feature pyramid network structure, different layers have different scales. The shallower the feature scale, the larger the spatial range represented, and the coarser the information granularity contained. Therefore, for the shallower attention map, the corresponding block scale is larger to cover a larger spatial area.
[0080] A feasible implementation method can determine the number of objects to be selected in each layer of the attention map by the following method: for any layer of the attention map, determine the number of layers corresponding to the attention map, and determine the number of blocks according to the number of layers corresponding to the attention map; divide the attention map into blocks according to the number of blocks to obtain multiple feature blocks; determine the response value of each feature block; and determine the number of objects to be selected in each layer of the attention map according to the response value of each feature block of each layer of the attention map.
[0081] Optionally, the scale of the feature block corresponding to each layer of the attention map is determined according to the correspondence between the number of layers and the scale of the feature block, and the number of blocks is determined according to the ratio of the scale of the attention map and the scale of the feature block.
[0082] Optionally, the response value of the central pixel of the feature block is determined by a detector, and the response value of the central pixel of the feature block is determined as the response value of the feature block.
[0083] Combined with the scene example, for each feature block, the response value of its central pixel on the attention map is extracted. The response value reflects the degree of attention received by the location on the attention map. Generally, the higher the response value, the more likely the location is to be the target area.
[0084] Specifically, a feasible implementation method can determine the number of candidates for selection of each layer of the attention map by the following method: for any feature block of each layer of the attention map, if the response value is less than or equal to the first threshold, the number of candidates for selection of the feature block is determined to be 0; if the response value is greater than the second threshold, the number of candidates for selection of the feature block is determined to be 1; if the response value is greater than the first threshold and less than or equal to the second threshold, the number of candidates for selection of the feature block is determined according to the product of the response value and the first value; according to the number of candidates for selection of each feature block in each layer of the attention map, the number of candidates for selection of each layer of the attention map is determined.
[0085] Among them, the first value is the inhibition factor.
[0086] Optionally, the response value of each feature block is determined separately by a sliding window.
[0087] Exemplarily, the response value judgment formula is:
[0088]
[0089] in, is the number of objects to be selected, W is the sliding window, S is the statistical calculation of pixels, δ is the response intensity, A i is the feature block, γ s is the first threshold, γ l is the second threshold, and μ is the suppression factor.
[0090] Combined with the scene example, if the response value of the feature block is less than or equal to the first threshold, it means that the response value is too small, and it is determined that the feature block area does not include the candidate object. If the response value of the feature block is greater than the second threshold, it means that the response value is too small, and it is determined that there is a candidate object in the feature block area that matches the scale of the layer, and the number of candidates can be directly counted. If the response value of the feature block is greater than the first threshold and less than or equal to the second threshold, it means that there are objects in the feature block area that do not match the scale of the layer. The statistical number is suppressed by the suppression factor to match the scale of the layer, thereby improving the recognition accuracy.
[0091] S406. According to the number of objects to be selected in each layer of the attention map, each layer of the attention map is subjected to pooling processing and a second fusion processing to obtain an output feature map corresponding to each layer of the attention map.
[0092] Next, combine Figure 6 The second merging process will be described.
[0093] Figure 6 This is a schematic diagram of the second fusion process provided in the embodiment of the present application. Figure 6 As shown, the input feature map of each layer is orthogonally compressed to obtain the corresponding attention map. The attention map of each layer is pooled and fused with the pooling result of the adjacent layer according to the fusion weight to obtain the corresponding output feature map.
[0094] A feasible implementation method can obtain the output feature map by the following method: according to the response value of each feature block of each layer of attention map, each layer of attention map is pooled to obtain the pooling result of each layer of attention map, and the pooling process includes average pooling process or maximum pooling process; for any layer of attention map, the weight is determined according to the number of objects to be selected in the attention map and the number of objects to be selected in the adjacent upper layer attention map of the attention map; according to the weight, the pooling result of the attention map is subjected to a second fusion process with the pooling result of the adjacent upper layer attention map of the attention map to obtain the output feature map corresponding to the attention map.
[0095] Optionally, to avoid information loss, selective pooling is used.
[0096] Exemplarily, the pooling formula is:
[0097]
[0098] Among them, δ p represents the response value after selective pooling, δ1 represents the response value threshold, P avg represents average pooling, P max represents the maximum pooling, R δ The pixel count threshold that represents the threshold for judging whether a large target is present in the pooling area, Rmin Indicates the pixel number threshold corresponding to the proportion of large target response.
[0099] Combined with the scene example, average pooling is to calculate the average number of pixels in the area as the pooling result, and maximum pooling is to use the maximum number of pixels in the area as the pooling result. If the response value is less than the response value threshold, it means that there are only objects that do not match the scale of the layer or no objects in the area. In this case, average pooling can be performed directly. If the response value is greater than the response value threshold, directly using the maximum pooling method will lead to false detection. This application counts the number of pixels whose response value is greater than the response value threshold. If the number is less than R min , for example, 1 / 3 of the pooled area, it proves that there is only noise in this area, and this area will be regarded as background during the pooling process. min , then use maximum pooling.
[0100] Exemplarily, the formula for the second fusion process is:
[0101]
[0102] Among them, P i is the output feature map of the i-th layer for subsequent prediction, A is the attention map, is the fusion weight when the i+1th layer feature is fused with the ith layer feature. This fusion weight realizes the weight distribution of adjacent layer features. Stands for selective pooling.
[0103] The calculation formula is:
[0104]
[0105] in, is the number of objects to be selected in the i+1th layer, is the number of objects to be selected in the i-th layer, and the quantity information is determined by the block statistics method.
[0106] Combined with the scenario example, refer to Figure 6 , in order to determine the output feature map of the second layer, the pooling result of the second layer, the pooling result of the third layer, and the fusion weights of the second layer and the third layer are determined respectively, and the pooling results of the second layer and the pooling results of the third layer are feature fused according to the fusion weights to obtain the output feature map of the second layer.
[0107] In this feasible implementation, the response value in the attention map is used as the quantity information to estimate the actual number of objects to be selected and the fusion weights are adaptively allocated based on this, which alleviates the semantic conflict problem in the feature fusion process of small target objects.
[0108] S407: Perform a first fusion process on the output feature map to obtain a target recognition result.
[0109] It should be noted that the execution process of S407 refers to S204 and will not be repeated here.
[0110] Figure 7 This is a schematic diagram of the structure of an image recognition device provided in an embodiment of the present application. Figure 7 As shown, the image recognition device 70 may include: a receiving module 71, an extraction module 72, a compression module 73, and a fusion module 74, wherein:
[0111] The receiving module 71 is used to receive an object recognition request, where the object recognition request includes an image to be recognized.
[0112] The extraction module 72 is used to perform feature extraction processing on the image to be identified according to the preset multiple extraction depths to obtain a multi-layer input feature map corresponding to the image to be identified. Figure 1 One to one correspondence.
[0113] The compression module 73 is used to perform orthogonal compression processing on the input feature map of any layer to obtain the attention map corresponding to the input feature map.
[0114] The fusion module 74 is used to perform a first fusion process on each layer of the attention map to obtain a target recognition result corresponding to the image to be recognized, and the target recognition result includes multiple target objects.
[0115] Optionally, the receiving module 71 may execute Figure 2 S201 in the embodiment.
[0116] Optionally, the extraction module 72 may execute Figure 2 S202 in the embodiment.
[0117] Optionally, the compression module 73 may execute Figure 2 S203 in the embodiment.
[0118] Optionally, the fusion module 74 may perform Figure 2 S204 in the embodiment.
[0119] It should be noted that the image recognition device shown in the embodiment of the present application can execute the technical solution shown in the above method embodiment, and its implementation principle and beneficial effects are similar, which will not be repeated here.
[0120] In a possible implementation, the compression module 73 is specifically configured to:
[0121] Determine multiple feature vectors of multiple dimensions of the input feature map, where the multiple feature vectors are orthogonal to each other, the multiple dimensions at least include a channel dimension, a high dimension, or a wide dimension, and the multiple dimensions correspond one-to-one to the multiple feature vectors;
[0122] Through residual connection, each feature vector is superimposed on the input feature map to obtain the attention map corresponding to the input feature map.
[0123] Figure 8 A schematic diagram of the structure of an image recognition device provided in an embodiment of the present application. Figure 7 Based on the embodiment shown, Figure 8 As shown, the image recognition device 80 further includes: a processing module 75 and an execution module 76, wherein:
[0124] The processing module 75 is used for:
[0125] Determine the output feature map corresponding to each layer of attention map;
[0126] The output feature map is subjected to a first fusion process to obtain a target recognition result.
[0127] In a possible implementation manner, the processing module 75 is specifically configured to:
[0128] Through the block statistics method, multiple candidates for selection in each layer of the attention map are determined;
[0129] According to the number of objects to be selected in each layer of the attention map, each layer of the attention map is subjected to pooling processing and a second fusion processing to obtain the output feature map corresponding to each layer of the attention map.
[0130] In a possible implementation manner, the processing module 75 is specifically configured to:
[0131] For any layer of attention map, determine the number of layers corresponding to the attention map, and determine the number of blocks according to the number of layers corresponding to the attention map;
[0132] The attention map is divided into blocks according to the number of blocks to obtain multiple feature blocks;
[0133] Determine the response value of each feature block;
[0134] According to the response value of each feature block of each layer of attention map, the number of objects to be selected in each layer of attention map is determined.
[0135] In a possible implementation manner, the processing module 75 is specifically configured to:
[0136] For any feature block of each layer of the attention map, if the response value is less than or equal to the first threshold, the number of candidate objects of the feature block is determined to be 0;
[0137] If the response value is greater than the second threshold, the number of objects to be selected in the feature block is determined to be 1;
[0138] If the response value is greater than the first threshold value and less than or equal to the second threshold value, the number of objects to be selected for the feature block is determined according to the product of the response value and the first value;
[0139] According to the number of candidate objects of each feature block of each layer of attention map, the number of candidate objects of each layer of attention map is determined.
[0140] The execution module 76 is used to:
[0141] According to the response value of each feature block of each layer of attention map, each layer of attention map is pooled to obtain the pooling result of each layer of attention map, and the pooling process includes average pooling process or maximum pooling process;
[0142] For any layer of attention map, determine the weight according to multiple candidate objects of the attention map and multiple candidate objects of the attention map of the adjacent upper layer of the attention map;
[0143] According to the weight, the pooling result of the attention map is fused with the pooling result of the adjacent upper layer attention map of the attention map to obtain the output feature map corresponding to the attention map.
[0144] Fig. 9 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application is shown in FIG. Fig. 9 As shown, the electronic device includes:
[0145] The electronic device includes a processor 291 and a memory 292; it may also include a communication interface 293 and a bus 294. The processor 291, the memory 292, and the communication interface 293 may communicate with each other through the bus 294. The communication interface 293 may be used for information transmission. The processor 291 may call the logic instructions in the memory 292 to execute the method of the above embodiment.
[0146] In addition, the logic instructions in the above-mentioned memory 292 can be implemented in the form of software functional units and can be stored in a computer-readable storage medium when sold or used as an independent product.
[0147] The memory 292 is a computer-readable storage medium that can be used to store software programs and computer executable programs, such as program instructions / modules corresponding to the methods in the embodiments of the present application. The processor 291 executes functional applications and data processing by running the software programs, instructions, and modules stored in the memory 292, that is, implementing the methods in the above method embodiments.
[0148] The memory 292 may include a program storage area and a data storage area, wherein the program storage area may store an operating system and an application required for at least one function; the data storage area may store data created according to the use of the terminal device, etc. In addition, the memory 292 may include a high-speed random access memory and may also include a non-volatile memory.
[0149] An embodiment of the present application provides a non-temporary computer-readable storage medium, in which computer-executable instructions are stored. When the computer-executable instructions are executed by a processor, they are used to implement the method as described in the above embodiment.
[0150] It should be noted that, for the aforementioned method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the described order of actions, because according to the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all optional embodiments, and the actions and modules involved are not necessarily required by the present application.
[0151] It should be further noted that, although the various steps in the flowchart are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless there is a clear description in this article, the execution of these steps is not strictly limited in order, and these steps can be executed in other orders. Moreover, at least a portion of the steps in the flowchart may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these sub-steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a portion of the sub-steps or stages of other steps.
[0152] It should be understood that the above-mentioned device embodiments are only illustrative, and the device of the present application can also be implemented in other ways. For example, the division of units / modules in the above-mentioned embodiments is only a logical function division, and there may be other division methods in actual implementation. For example, multiple units, modules or components can be combined, or can be integrated into another system, or some features can be ignored or not executed.
[0153] In addition, unless otherwise specified, each functional unit / module in each embodiment of the present application may be integrated into one unit / module, each unit / module may exist physically separately, or two or more units / modules may be integrated together. The above-mentioned integrated unit / module may be implemented in the form of hardware or in the form of a software program module.
[0154] If the integrated unit / module is implemented in the form of hardware, the hardware may be a digital circuit, an analog circuit, etc. The physical implementation of the hardware structure includes but is not limited to transistors, etc. Unless otherwise specified, the processor may be any appropriate hardware processor, such as CPU, GPU, FPGA, DSP, and ASIC, etc. Unless otherwise specified, the storage unit may be any appropriate magnetic storage medium or magneto-optical storage medium, such as Resistive Random Access Memory (RRAM), Dynamic Random Access Memory (DRAM), Static Random Access Memory (SRAM), Enhanced Dynamic Random Access Memory (EDRAM), High-Bandwidth Memory (HBM), Hybrid Memory Cube (HMC), etc.
[0155] If the integrated unit / module is implemented in the form of a software program module and sold or used as an independent product, it can be stored in a computer-readable memory. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a memory, including a number of instructions to enable a computer device (which can be a personal computer, server or network device, etc.) to execute all or part of the steps of the various embodiments of the present application. The aforementioned memory includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, disk or optical disk and other media that can store program codes.
[0156] In the above embodiments, the description of each embodiment has its own emphasis. For parts not described in detail in a certain embodiment, please refer to the relevant description of other embodiments. The technical features of the above embodiments can be combined arbitrarily. In order to make the description concise, all possible combinations of the technical features in the above embodiments are not described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0157] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the invention disclosed herein. The present application is intended to cover any modification, use or adaptation of the present application, which follows the general principles of the present application and includes common knowledge or customary techniques in the art that are not disclosed in the present application. The specification and examples are intended to be exemplary only, and the true scope and spirit of the present application are indicated by the following claims.
[0158] It should be understood that the present application is not limited to the precise structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present application is limited only by the appended claims.
Claims
1. An image recognition method, characterized in that: include: receiving an object recognition request, wherein the object recognition request includes an image to be recognized; Performing feature extraction processing on the image to be identified through multiple extraction depths of a feature pyramid network to obtain a multi-layer input feature map corresponding to the image to be identified, wherein the multiple extraction depths correspond to the multi-layer input feature map one by one; For any layer of input feature map, perform orthogonal compression processing on the input feature map to obtain an attention map corresponding to the input feature map; Performing a first fusion process on each layer of the attention map to obtain a target recognition result corresponding to the image to be recognized, wherein the target recognition result includes multiple target objects; Performing orthogonal compression processing on the input feature map to obtain an attention map corresponding to the input feature map, including: Determine a plurality of feature vectors of a plurality of dimensions of the input feature map, wherein the plurality of feature vectors are in an orthogonal relationship, the plurality of dimensions include a channel dimension, a high dimension, and a wide dimension, and the plurality of dimensions correspond one-to-one to the plurality of feature vectors; Each feature vector is superimposed on the input feature map by residual connection to obtain an attention map corresponding to the input feature map; The formula for generating the attention map is: Among them, i is the number of layers, A i is the attention map, C i is the input feature map, is the feature vector of the input feature map channel dimension, is the high-dimensional feature vector of the input feature map, is the feature vector of the wide dimension of the input feature map.
2. The method according to claim 1, characterized in that Performing a first fusion process on each layer of the attention map to obtain a target recognition result corresponding to the image to be recognized, including: Determine the output feature map corresponding to each layer of attention map; A first fusion process is performed on the output feature map to obtain the target recognition result.
3. The method according to claim 2, characterized in that Determine the output feature map corresponding to each layer of attention map, including: Determine the number of objects to be selected in each layer of the attention map by block statistics; According to the number of objects to be selected in each layer of the attention map, each layer of the attention map is subjected to pooling processing and a second fusion processing to obtain an output feature map corresponding to each layer of the attention map.
4. The method according to claim 3, characterized in that The number of objects to be selected in each layer of the attention map is determined by block statistics, including: For any layer of attention map, determine the number of layers corresponding to the attention map, and determine the number of blocks according to the number of layers corresponding to the attention map; Divide the attention map into blocks according to the number of blocks to obtain multiple feature blocks; Determine the response value of each feature block; According to the response value of each feature block of each layer of the attention map, the number of objects to be selected in each layer of the attention map is determined.
5. The method according to claim 4, characterized in that According to the response value of each feature block of each layer of the attention map, determining the number of objects to be selected in each layer of the attention map, including: For any one of the feature blocks of each layer of the attention map, if the response value is less than or equal to the first threshold, determining the number of objects to be selected for the feature block to be 0; If the response value is greater than the second threshold, determining that the number of objects to be selected for the feature block is 1; If the response value is greater than the first threshold value and less than or equal to the second threshold value, the number of objects to be selected for the feature block is determined according to the product of the response value and a first value; wherein the first value is a suppression factor; According to the number of candidate objects of each feature block of each layer of attention map, the number of candidate objects of each layer of attention map is determined.
6. The method according to claim 4 or 5, characterized in that: According to the number of objects to be selected in each layer of the attention map, each layer of the attention map is subjected to pooling processing and a second fusion processing to obtain an output feature map corresponding to each layer of the attention map, including: According to the response value of each feature block of each layer of attention map, each layer of attention map is pooled to obtain a pooling result of each layer of attention map, wherein the pooling process includes average pooling process or maximum pooling process; For any layer of attention map, determine the weight according to the number of objects to be selected in the attention map and the number of objects to be selected in the adjacent upper layer attention map of the attention map; According to the weight, a second fusion process is performed on the pooling result of the attention map and the pooling result of the adjacent upper layer attention map of the attention map to obtain an output feature map corresponding to the attention map.
7. An image recognition device, characterized in that: include: A receiving module, configured to receive an object recognition request, wherein the object recognition request includes an image to be recognized; An extraction module, used to perform feature extraction processing on the image to be identified through multiple extraction depths of a feature pyramid network to obtain a multi-layer input feature map corresponding to the image to be identified, wherein the multiple extraction depths correspond to the multi-layer input feature map in a one-to-one manner; A compression module, for performing orthogonal compression processing on an input feature map of any layer to obtain an attention map corresponding to the input feature map; A fusion module is used to perform a first fusion process on each layer of the attention map to obtain a target recognition result corresponding to the image to be recognized, wherein the target recognition result includes multiple target objects; The compression module is specifically used for: Determine a plurality of feature vectors of a plurality of dimensions of the input feature map, wherein the plurality of feature vectors are in an orthogonal relationship, the plurality of dimensions include a channel dimension, a high dimension, and a wide dimension, and the plurality of dimensions correspond one-to-one to the plurality of feature vectors; Each feature vector is superimposed on the input feature map by residual connection to obtain an attention map corresponding to the input feature map; The formula for generating the attention map is: Among them, i is the number of layers, A i is the attention map, C i is the input feature map, is the feature vector of the input feature map channel dimension, is the high-dimensional feature vector of the input feature map, is the feature vector of the wide dimension of the input feature map.
8. An electronic device, characterized in that: include: A processor, and a memory communicatively connected to the processor; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory to implement the method according to any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, which are used to implement the method according to any one of claims 1 to 6 when executed by a processor.
