Target detection method, system, device and medium
By performing pooling calculation and weight adjustment on image feature maps, the problems of high complexity and poor adaptability of existing models are solved, and the accuracy and information richness of target detection are improved.
Patent Information
- Application Number
- CN202410772466.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-14
- Publication Date
- 2024-08-30
AI Technical Summary
Existing target detection models based on the self-attention mechanism need to build deep neural networks, which increases model complexity and training difficulty. More model parameters need to be adjusted when adapting to different target detection tasks, and conventional models ignore the differences in images. importance of the region.
By performing pooling calculations on the image feature maps, the first feature map is obtained, and multiple calculations are performed using the first weight and the second weight. Finally, target detection is performed based on the third feature map to increase attention to important feature information and to Filter interference information and reduce the weight of background features, thereby improving detection accuracy.
Through two attention calculations, we pay more attention to important feature information, adaptively filter interference information, and improve the information richness of the extracted target feature map, thereby improving the detection accuracy.
Smart Images

Figure CN118570451A
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image target detection, and in particular to a target detection method, system, equipment and medium. Background Art
[0002] The purpose of target detection is to identify specific targets from an image. In traditional target detection methods, the model often processes the entire image globally, ignoring the importance of different regions in the image. After the introduction of the attention mechanism, the model can automatically adjust the degree of attention to different regions according to the image content, thereby detecting targets more effectively. The application of the attention mechanism in target detection can increase the model's attention to different regions in the image, thereby improving detection performance.
[0003] Therefore, model algorithms based on attention mechanism for target detection are becoming increasingly important in the field of image target detection. Self-attention mechanism can help the model extract effective foreground features of the image in target detection, but common model algorithms based on self-attention mechanism require the construction of deep neural networks to be implemented, which increases the complexity and training difficulty of the model, and when adapting to different target detection tasks, more model parameters need to be adjusted. Summary of the invention
[0004] In view of this, in order to overcome at least one aspect of the above problems, an embodiment of the present invention provides a target detection method, comprising the following steps: Performing pooling calculation on the image feature map to obtain a first feature map; Obtaining a first weight based on the first feature map, and obtaining a second feature map using the first weight and the corresponding first feature map; Obtaining a second weight based on the second feature map; A third feature map is calculated using the second weight and the image feature map, and target detection is performed based on the third feature map.
[0005] In some embodiments, performing pooling calculation on the image feature map to obtain the first feature map further includes: Performing multiple pooling calculations on each channel of the image feature map to obtain multiple pooling feature maps corresponding to each channel; The multiple pooled feature maps corresponding to each channel are concatenated to obtain the first feature map corresponding to each channel.
[0006] In some embodiments, performing multiple pooling calculations on each channel of the image feature map to obtain multiple pooling feature maps corresponding to each channel further includes: Global standard deviation pooling calculation, global maximum pooling calculation, and global average pooling calculation are performed on each channel of the image feature map to obtain corresponding multiple pooling feature maps.
[0007] In some embodiments, obtaining a first weight based on the first feature map, and obtaining a second feature map using the first weight and the corresponding first feature map further includes: Calculating the first feature map using a first neural network and normalizing the calculation results to obtain a plurality of first weights corresponding to each channel, wherein the number of layers of the first neural network is a first preset number of layers, and the number of neurons in each layer is a first preset number; The multiple pooling feature maps corresponding to each channel are multiplied by the corresponding first weights respectively, and the multiplication results are concatenated to obtain the second feature map corresponding to each channel.
[0008] In some embodiments, obtaining a second weight based on the second feature map further includes: The second feature map is calculated using a second neural network and the calculation result is normalized to obtain a second weight corresponding to each channel, wherein the number of layers of the second neural network is a second preset number of layers, and the number of neurons in each layer is a second preset number.
[0009] In some embodiments, calculating the corresponding third feature map using the second weight and the image feature map further includes: Multiply each feature point of the image feature map by the second weight of the corresponding channel to obtain a third feature map.
[0010] In some embodiments, performing target detection based on the third feature map further includes: Determine whether the accuracy of the target detection result reaches a threshold; In response to the accuracy rate not reaching a threshold, the first neural network and the second neural network are trained to adjust the first weight and the second weight.
[0011] Based on the same inventive concept, according to another aspect of the present invention, an embodiment of the present invention further provides a target detection system, including: A pooling module, configured to perform pooling calculation on the image feature map to obtain a first feature map; A first weight module, configured to obtain a first weight based on the first feature map, and obtain a second feature map using the first weight and the corresponding first feature map; A second weight module, configured to obtain a second weight based on the second feature map; A calculation module is configured to calculate a third feature map using the second weight and the image feature map and perform target detection based on the target feature map.
[0012] Based on the same inventive concept, according to another aspect of the present invention, an embodiment of the present invention further provides a computer device, including: at least one processor; and A memory, wherein the memory stores a computer program that can be run on the processor, and when the processor executes the program, the steps of any one of the target detection methods described above are performed.
[0013] Based on the same inventive concept, according to another aspect of the present invention, an embodiment of the present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of any one of the target detection methods described above are performed.
[0014] The present invention has one of the following beneficial technical effects: the scheme proposed in the present invention calculates the input feature map twice through the first weight and the second weight, which can add extra attention to important feature information and adaptively filter or suppress interference information, thereby improving the information richness of the extracted target feature map and further improving the detection accuracy. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments of the present invention. For ordinary technicians in this field, other embodiments can be obtained based on these drawings without paying creative work.
[0016] Figure 1 A schematic diagram of a flow chart of a target detection method provided by an embodiment of the present invention; Figure 2 A flowchart of a target detection method provided by an embodiment of the present invention; Figure 3 A schematic diagram of the structure of a target detection system provided by an embodiment of the present invention; Figure 4 A schematic diagram of the structure of a computer device provided by an embodiment of the present invention; Figure 5 A schematic diagram of the structure of a computer-readable storage medium provided for an embodiment of the present invention. DETAILED DESCRIPTION
[0017] In order to make the objectives, technical solutions and advantages of the present invention more clearly understood, the embodiments of the present invention are further described in detail below in combination with specific embodiments and with reference to the accompanying drawings.
[0018] It should be noted that all expressions using "first" and "second" in the embodiments of the present invention are for distinguishing two non-identical entities with the same name or non-identical parameters. It can be seen that "first" and "second" are only for the convenience of expression and should not be understood as limitations on the embodiments of the present invention. The subsequent embodiments will not explain this one by one.
[0019] According to one aspect of the present invention, an embodiment of the present invention provides a target detection method, such as Figure 1 As shown, it may include the steps of: S1, performing pooling calculation on the image feature map to obtain a first feature map; S2, obtaining a first weight based on the first feature map, and obtaining a second feature map using the first weight and the corresponding first feature map; S3, obtaining a second weight based on the second feature map; S4: Calculate a third feature map using the second weight and the image feature map, and perform target detection based on the third feature map.
[0020] The solution proposed in the present invention calculates the input image feature map twice through the first weight and the second weight, which can add extra attention to important feature information and adaptively filter or suppress interference information, thereby increasing the weight of the extracted foreground target and reducing the weight of the background or interference object features, thereby improving the detection accuracy.
[0021] In some embodiments, performing pooling calculation on the image feature map to obtain the first feature map further includes: Performing multiple pooling calculations on each channel of the image feature map to obtain multiple pooling feature maps corresponding to each channel; The multiple pooled feature maps corresponding to each channel are concatenated to obtain the first feature map corresponding to each channel.
[0022] In some embodiments, performing multiple pooling calculations on each channel of the image feature map to obtain multiple pooling feature maps corresponding to each channel further includes: Global standard deviation pooling calculation, global maximum pooling calculation, and global average pooling calculation are performed on each channel of the image feature map to obtain corresponding multiple pooling feature maps.
[0023] In some embodiments, it also includes: according to Calculate the global average pooling feature map; according to Calculate the global standard error pooling feature map; according to Calculate the global maximum pooling feature map; Among them, c is the image feature map channel, W is the width of the feature map, and H is the height of the feature map. Indicates the feature point value with channel c, horizontal coordinate w, and vertical coordinate h.
[0024] Specifically, Figure 2 As shown in the figure, for the input C*W*H image, global standard deviation pooling, global maximum pooling, and global average pooling can be performed according to the channel to obtain three 1×1×C feature maps corresponding to each channel, and then the above three pooling calculation results are concatenated using the concat function to obtain the first feature map. In this way, multiple calculation methods are used in the pooling calculation and the first weight is adaptively adjusted according to the first feature map, so that the information of the extracted key features is richer than that of the common channel self-attention mechanism network (such as SEnet, SRM, CBAM), and the model can quickly learn the target feature information, ignore or suppress the interfering background features, and improve the model detection accuracy.
[0025] In some embodiments, obtaining a first weight based on the first feature map, and obtaining a second feature map using the first weight and the corresponding first feature map further includes: Calculating the first feature map using a first neural network and normalizing the calculation results to obtain a plurality of first weights corresponding to each channel, wherein the number of layers of the first neural network is a first preset number of layers, and the number of neurons in each layer is a first preset number; The multiple pooling feature maps corresponding to each channel are multiplied by the corresponding first weights respectively, and the multiplication results are concatenated to obtain the second feature map corresponding to each channel.
[0026] Specifically, Figure 2As shown, after several pooling feature maps are spliced, the splicing result can be input into the pooling attention mechanism module, which includes a first neural network and a normalization function module. The first neural network is used to calculate the input splicing result, and the calculation will obtain several 1×1×C feature maps (C is the number of channels), and the number of feature maps calculated is the same as the number of pooling feature maps. Then, the normalization function module is used to calculate several 1×1×C feature maps to obtain the importance weight value (first weight) corresponding to each pooling feature map, and the sum of the weight values of all first weights is equal to 1. This feature weight obtained by adaptive learning during the model training process can automatically adjust the weight parameters according to different training data sets, so that the model can learn more valuable features for target detection and ignore or reduce background features. Finally, the first weights obtained above are multiplied by the corresponding pooling feature maps and then spliced to obtain the second feature map.
[0027] For example, the first neural network can be a multilayer perceptron (MLP), or other types of neural networks. To improve computational efficiency, the number of layers N of the multilayer perceptron can be 3, the number of neurons in each layer is equal to the number of channels of the image, the activation function is ReLU, and the MLP is used to calculate several input pooling feature maps, and then the calculation results are input into the normalization function to obtain the weight corresponding to each pooling feature map. If the number of pooling feature maps is 3, three weight values k1, k2, and k3 are obtained, and k1+k2+k3=1. Finally, the feature maps obtained by multiplying k1 by the global standard deviation pooling feature map, k2 by the global maximum pooling feature map, and k3 by the global average pooling feature map are spliced by channel to obtain the second feature map.
[0028] In some embodiments, obtaining a channel weight corresponding to each channel based on the first attention feature map further includes: The second feature map is calculated using a second neural network and the calculation result is normalized to obtain a second weight corresponding to each channel, wherein the number of layers of the second neural network is a second preset number of layers, and the number of neurons in each layer is a second preset number.
[0029] Specifically, Figure 2As shown, after obtaining each first weight, the first weight is multiplied by the corresponding pooled feature map, and the results are spliced by channel to obtain the second feature map. Then the second feature map is input into the channel attention mechanism module, which includes a second neural network and a normalization function module. The second neural network is used to calculate the second feature map, and then the calculation result of the second neural network is input into the normalization function to calculate the importance weight value (second weight) of each channel. Finally, the second weight is multiplied by the input C*H*W image to obtain the third feature map.
[0030] For example, the second neural network can be a multilayer perceptron (MLP), or other types of neural networks. The number of layers N of the multilayer perceptron can be 3, the number of neurons in each layer is equal to the number of channels of the image, and the activation function is ReLU. If the pooled feature maps obtained are the first pooled feature map, the second pooled feature map, and the third pooled feature map, and their corresponding pooling weights are K1, K2, and K3, respectively, then the feature maps obtained by the first pooled feature map * K1, the second pooled feature map * K2, and the third pooled feature map * K3 are spliced by channel to obtain the second feature map, and then the second feature map is input into the MLP. After the MLP calculation, it is input into the normalization function for calculation to obtain the importance weight value of each channel. If the number of channels is 3, 3 weight values c1, c2, and c3 are obtained, and c1+c2+c3=1.
[0031] In some embodiments, the method further includes performing normalization based on the following formula:
[0032] in, Represents the input value for normalization calculation, e is a natural constant, and n is the number of input values.
[0033] Specifically, when the first neural network and the second neural network are subjected to normalization calculation, the Softmax function may be used for normalization calculation. For example, when calculating the three 1×1×C feature maps output by the first neural network, the value of n is 3. x i Take the corresponding 1×1×C feature maps respectively. Similarly, when calculating the three feature maps output by the second neural network, n takes the value of 3. x i Take the corresponding feature maps respectively.
[0034] In some embodiments, performing target detection based on the target feature map further includes: Determine whether the accuracy of the target detection result reaches a threshold; In response to the accuracy rate not reaching a threshold, the first neural network and the second neural network are trained to adjust the pooling weights and the channel weights.
[0035] Specifically, when target detection is performed based on the target feature map, if the accuracy of the detection result does not reach the threshold, back propagation can be performed according to the loss function to train the first neural network and the second neural network, update the parameters of the first neural network and the second neural network, and adjust the obtained first weight and second weight. Or when the detection target is changed, for example, from detecting vehicles in vehicle-road cooperative image data to detecting faces in images, the first neural network and the second neural network are retrained on a new data set, the parameters of the first neural network and the second neural network are adjusted, and the first weight and the second weight are adjusted at the same time, so that the network can learn more about face targets.
[0036] The solution proposed in the present invention performs two attention calculations on the input feature map through the pooling attention mechanism module and the channel attention mechanism module, which can add extra attention to important feature information and adaptively filter or suppress interference information, thereby improving the information richness of the extracted target feature map and further improving the detection accuracy.
[0037] Based on the same inventive concept, according to another aspect of the present invention, an embodiment of the present invention further provides a target detection system 400, such as Figure 3 As shown, including: A pooling module 401 is configured to perform pooling calculation on the image feature map to obtain a first feature map; A first weight module 402 is configured to obtain a first weight based on the first feature map, and obtain a second feature map using the first weight and the corresponding first feature map; A second weight module 403, configured to obtain a second weight based on the second feature map; The calculation module 404 is configured to calculate a third feature map using the second weight and the image feature map and perform target detection based on the target feature map.
[0038] In some embodiments, the pooling module 401 is further configured to: Performing multiple pooling calculations on each channel of the image feature map to obtain multiple pooling feature maps corresponding to each channel; The multiple pooled feature maps corresponding to each channel are concatenated to obtain the first feature map corresponding to each channel.
[0039] In some embodiments, the pooling module 401 is further configured to: Global standard deviation pooling calculation, global maximum pooling calculation, and global average pooling calculation are performed on each channel of the image feature map to obtain corresponding multiple pooling feature maps.
[0040] In some embodiments, the first weight module 402 is further configured to: Calculating the first feature map using a first neural network and normalizing the calculation results to obtain a plurality of first weights corresponding to each channel, wherein the number of layers of the first neural network is a first preset number of layers, and the number of neurons in each layer is a first preset number; The multiple pooling feature maps corresponding to each channel are multiplied by the corresponding first weights respectively, and the multiplication results are added to obtain the second feature map corresponding to each channel.
[0041] In some embodiments, the second weight module 403 is further configured to: The second feature map is calculated using a second neural network and the calculation result is normalized to obtain a second weight corresponding to each channel, wherein the number of layers of the second neural network is a second preset number of layers, and the number of neurons in each layer is a second preset number.
[0042] In some embodiments, the computing module is further configured to: Multiply each feature point of the image feature map by the second weight of the corresponding channel to obtain a third feature map.
[0043] In some embodiments, the training module is configured to: Determine whether the accuracy of the target detection result reaches a threshold; In response to the accuracy rate not reaching a threshold, the first neural network and the second neural network are trained to adjust the first weight and the second weight.
[0044] The solution proposed in the present invention performs two attention calculations on the input feature map through the first weight and the second weight, which can add extra attention to important foreground feature information and adaptively filter or suppress background interference information, thereby improving the information richness of the extracted target feature map and further improving the detection accuracy.
[0045] Based on the same inventive concept, according to another aspect of the present invention, Figure 4 As shown, an embodiment of the present invention further provides a computer device 501, including: at least one processor 520; and The memory 510 stores a computer program 511 that can be run on the processor. When the processor 520 executes the program, the steps of any one of the above target detection methods are performed.
[0046] Based on the same inventive concept, according to another aspect of the present invention, Figure 5 As shown, an embodiment of the present invention further provides a computer-readable storage medium 601, which stores a computer program 610. When the computer program 610 is executed by a processor, the steps of any of the above target detection methods are performed.
[0047] Finally, it should be noted that a person skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be implemented by instructing related hardware through a computer program, and the program can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above-mentioned methods.
[0048] Furthermore, it should be appreciated that the computer-readable storage medium (eg, memory) herein may be either volatile memory or nonvolatile memory, or may include both volatile memory and nonvolatile memory.
[0049] It will also be appreciated by those skilled in the art that various exemplary logic blocks, modules, circuits and algorithm steps described in conjunction with the disclosure herein can be implemented as electronic hardware, computer software or a combination of the two. In order to clearly illustrate this interchangeability of hardware and software, a general description has been given to the functions of various schematic components, blocks, modules, circuits and steps. Whether this function is implemented as software or hardware depends on specific applications and the design constraints imposed on the entire system. Those skilled in the art can implement the function in various ways for each specific application, but this implementation decision should not be interpreted as causing a departure from the disclosed scope of the embodiments of the present invention.
[0050] The above are exemplary embodiments disclosed in the present invention, but it should be noted that various changes and modifications may be made without departing from the scope disclosed in the embodiments of the present invention as defined in the claims. The functions, steps and / or actions of the method claims according to the disclosed embodiments described herein do not need to be performed in any particular order. In addition, although the elements disclosed in the embodiments of the present invention may be described or required in individual form, they may also be understood as multiple unless explicitly limited to the singular.
[0051] It should be understood that, as used herein, the singular forms "a", "an" are intended to include the plural forms as well, unless the context clearly supports an exception. It should also be understood that, as used herein, "and / or" refers to any and all possible combinations including one or more of the associated listed items.
[0052] The serial numbers of the embodiments disclosed in the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.
[0053] A person skilled in the art will understand that all or part of the steps to implement the above embodiments may be accomplished by hardware or by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, and the above-mentioned storage medium may be a read-only memory, a disk or an optical disk, etc.
[0054] A person skilled in the art should understand that the discussion of any of the above embodiments is only exemplary and is not intended to imply that the scope of the disclosure of the embodiments of the present invention (including the claims) is limited to these examples; under the concept of the embodiments of the present invention, the technical features in the above embodiments or different embodiments can also be combined, and there are many other changes in different aspects of the above embodiments of the present invention, which are not provided in detail for the sake of simplicity. Therefore, any omissions, modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the embodiments of the present invention should be included in the protection scope of the embodiments of the present invention.
Claims
1. A target detection method, It is characterized in that The following steps are involved: Performing pooling calculation on the image feature map to obtain a first feature map; Obtaining a first weight based on the first feature map, and obtaining a second feature map using the first weight and the corresponding first feature map; Obtaining a second weight based on the second feature map; A third feature map is calculated using the second weight and the image feature map, and target detection is performed based on the third feature map.
2. The method according to claim 1, It is characterized in that Performing pooling calculation on the image feature map to obtain a first feature map further includes: Performing multiple pooling calculations on each channel of the image feature map to obtain multiple pooling feature maps corresponding to each channel; The multiple pooled feature maps corresponding to each channel are concatenated to obtain the first feature map corresponding to each channel.
3. The method according to claim 2, It is characterized in that Performing multiple pooling calculations on each channel of the image feature map to obtain multiple pooling feature maps corresponding to each channel further includes: Global standard deviation pooling calculation, global maximum pooling calculation, and global average pooling calculation are performed on each channel of the image feature map to obtain corresponding multiple pooling feature maps.
4. The method according to claim 2, It is characterized in that Obtaining a first weight based on the first feature map, and obtaining a second feature map using the first weight and the corresponding first feature map, further comprising: Calculating the first feature map using a first neural network and normalizing the calculation results to obtain a plurality of first weights corresponding to each channel, wherein the number of layers of the first neural network is a first preset number of layers, and the number of neurons in each layer is a first preset number; The multiple pooling feature maps corresponding to each channel are multiplied by the corresponding first weights respectively, and the multiplication results are concatenated to obtain the second feature map corresponding to each channel.
5. The method according to claim 4, It is characterized in that Obtaining a second weight based on the second feature map further includes: The second feature map is calculated using a second neural network and the calculation result is normalized to obtain a second weight corresponding to each channel, wherein the number of layers of the second neural network is a second preset number of layers, and the number of neurons in each layer is a second preset number.
6. The method according to claim 5, It is characterized in that Calculating a corresponding third feature map using the second weight and the image feature map further includes: Multiply each feature point of the image feature map by the second weight of the corresponding channel to obtain a third feature map.
7. The method according to claim 5, It is characterized in that Performing target detection based on the third feature map further includes: Determine whether the accuracy of the target detection result reaches a threshold; In response to the accuracy rate not reaching a threshold, the first neural network and the second neural network are trained to adjust the first weight and the second weight.
8. A target detection system, It is characterized in that include: A pooling module, configured to perform pooling calculation on the image feature map to obtain a first feature map; A first weight module, configured to obtain a first weight based on the first feature map, and obtain a second feature map using the first weight and the corresponding first feature map; A second weight module, configured to obtain a second weight based on the second feature map; A calculation module is configured to calculate a third feature map using the second weight and the image feature map and perform target detection based on the target feature map.
9. A computer device, include: at least one processor; as well as A memory storing a computer program executable on the processor, wherein the processor executes the steps of the method according to any one of claims 1 to 7 when executing the program.
10. A computer-readable storage medium storing a computer program. It is characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are performed.
Citation Information
Cited By
Fruit target detection method based on lightweight multi-scale attention mechanism
CN120259793A
A fruit target detection method based on a lightweight multi-scale attention mechanism
CN120259793B
Adaptive heterogeneous decoupling detection head based on multi-dimensional scene representation
CN122657616A
Adaptive heterogeneous decoupled detection head based on multi-dimensional scene representation
CN122657616B
