Target detection method based on collaborative attention mechanism multi-scale target detection network
By introducing the collaborative attention mechanism and optimized DarkNet-53 model into the target detection network, combined with mosaic data enhancement and adaptive anchor point calculation, the problem of target detection accuracy and speed in complex scenes is solved, and efficient recognition of targets is achieved. and distinction.
Patent Information
- Application Number
- CN202410617173.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-17
- Publication Date
- 2024-08-30
AI Technical Summary
Existing target detection methods are difficult to effectively learn fine-grained information and distinguish targets from background in complex scenes, resulting in low detection accuracy and slow inference speed, especially when the target size is small or the contrast is low.
A multi-scale target detection network based on a collaborative attention mechanism is used, through the optimized DarkNet-53 model and the feature enhancement module in the neck network, combined with mosaic data enhancement and adaptive anchor point calculation, to improve feature extraction and background suppression capabilities.
It effectively retains tiny target features in images, reduces background interference, improves detection accuracy and reasoning speed, and is suitable for multi-category target detection tasks in complex scenes.
Smart Images

Figure CN118570633A
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of intelligent target detection, and in particular to a target detection method based on a multi-scale target detection network with a collaborative attention mechanism. Background Art
[0002] As a core research branch of computer vision, object detection has long received extensive attention from the academic community. However, it is still extremely challenging to perform object detection tasks in visual scenes that contain diverse, densely distributed, mutually occluded objects, as well as visual scenes affected by complex lighting, changing terrain, and dynamic target interactions.
[0003] In order to improve the detection accuracy of various targets in complex scenes, several studies have attempted to optimize detection by focusing on target clustering areas. However, such methods usually include two independent stages (extracting candidate target areas, classifying and fine-positioning candidate areas), which results in high computational complexity and slow inference speed, limiting its applicability in applications with high real-time requirements. In addition, some works optimize feature representation by encoding contextual information to improve the detection performance of the model. For example, multi-scale feature fusion technology is used to integrate local and global information, alleviate the negative impact of target scale changes on model accuracy, and improve detection accuracy. There are also some works that improve detection performance by detecting feature maps at each level separately. Although these methods have made great progress, they still have the following shortcomings:
[0004] First, most of these methods ignore the problem of fine-grained information loss during the downsampling process, which makes it difficult for the model to learn effective feature representation. Most of the current methods use conventional convolution blocks to perform downsampling operations in the feature extraction stage. In this process, small objects in the image or fine structural features of the object are easily lost, making it difficult for the model to capture enough detailed information.
[0005] In addition, these methods are difficult to effectively suppress the interference of background information, resulting in low detection accuracy and slow inference speed of the model. Complex background features are easily confused with target features, especially when the target size is small or the contrast is low. The model may pay too much attention to background features during the learning process and ignore the learning and distinction of target features, which leads to unstable detection of targets in the inference stage and misjudgment.
[0006] For example, Figure 1 In the figure, in the general image on the left, the target "bus" has a high pixel ratio in the entire image, and the model can learn richer contextual information in the target; while in the image of the complex scene on the right, most of the pixels are background, and the target pixels such as "pedestrians" and "bicycles" have a low ratio, so it is difficult for the model to learn effective feature expressions and cannot effectively distinguish between the target and the background.
[0007] Therefore, how to improve the efficiency and accuracy of target detection in complex scenes has become a problem that needs to be solved urgently. Summary of the invention
[0008] In view of the above-mentioned deficiencies in the prior art, the present invention provides a target detection method based on a multi-scale target detection network with a collaborative attention mechanism, which can improve the efficiency and accuracy of target detection in complex scenes.
[0009] In order to solve the above technical problems, the present invention adopts the following technical solutions:
[0010] The target detection method based on the collaborative attention mechanism multi-scale target detection network includes the following steps:
[0011] S1. Build a target detection model; the target detection model includes a backbone network, a neck network, and a prediction head;
[0012] The backbone network includes an optimized DarkNet-53 model, and the backbone network is used to extract features of different levels from the input image using the optimized DarkNet-53 model;
[0013] The neck network is used to further process and integrate the features extracted by the backbone network. A feature enhancement module based on the collaborative attention mechanism is embedded in the neck network to enable the target detection model to focus on the target itself.
[0014] The prediction head is used to process the features output by the neck network and generate the final target detection result;
[0015] S2, acquiring image data and preprocessing it to obtain a training data set for the target detection model;
[0016] S3, use the training data set obtained in S2 to train the target detection model;
[0017] S4. Use the trained target detection model to perform actual target detection.
[0018] Compared with the prior art, the present invention has the following beneficial effects:
[0019] 1. In the target detection model constructed by this method, the backbone network uses the optimized DarkNet-53 model to extract features at different levels of the output image. Compared with the use of conventional convolution blocks for downsampling operations, the downsampling of the DarkNet-53 model is mainly achieved through convolution and pooling operations, which can reduce the size of the feature map while retaining important feature information. In this way, the target detection model can retain small targets or fine structural features of the target in the image during the downsampling process, and can capture sufficient detail information in the subsequent recognition process. It effectively avoids the problem of small target feature loss caused by downsampling in the feature extraction stage.
[0020] 2 In the target detection model constructed by this method, the neck network introduces a feature enhancement module based on the collaborative attention mechanism, which can effectively suppress redundant background information without significantly increasing the computational cost, so that the model can focus more on the target itself and improve the detection accuracy. This multi-scale target detection system based on the collaborative attention mechanism can effectively solve the problem of interference from background information. Even when the target size is small or the contrast is low, it will not pay too much attention to the background features during the learning process, which can ensure the learning and differentiation of target features, thereby ensuring the detection accuracy and reasoning speed of the model in the inference stage.
[0021] 3. The target detection model in this method has the characteristics of lightweight deployment, efficient algorithm, and high retrieval accuracy. It can be applied to target detection in the Internet, drone or sensor images, and provides a new solution for multi-category target detection tasks in complex scenarios.
[0022] In summary, this method can improve the efficiency and accuracy of target detection in complex scenes.
[0023] Preferably, when the backbone network uses the optimized DarkNet-53 model to extract features of different levels from the input image, the process of the downsampling stage includes: for the input image X; first, use a convolution kernel of size 3×3 with a step size of 1 to extract the deep features of the image to generate an initial feature map F(x, y); then, according to the set downsampling factor s, the initial feature map F(x, y) is divided into a series of sub-feature maps f(x, y); finally, these sub-feature maps are spliced along the channel dimension to obtain a new feature mosaic data enhancement map F′.
[0024] Compared with using conventional convolution blocks for downsampling operations, such downsampling operations can effectively avoid the problem of small target feature loss caused by downsampling in the feature extraction stage.
[0025] Preferably, in the target detection module, the related work of the feature enhancement module based on the collaborative attention mechanism includes:
[0026] First, the number of channels of the input feature map is reduced to half through a 1×1 convolution, and then restored to the original value through a 3×3 convolution; then, attention calculation is performed on the feature map;
[0027] The process of attention calculation for the feature map includes: for the feature map F, using the pooling kernels of size H×1 and 1×W along the X and Y axis directions respectively to generate the feature map f x and f y ; Then, use 1×1 convolution to increase the dimension of these features, and combine with Sigmoid activation function to generate attention vector g h and g w ; Finally, by comparing the feature map F with its corresponding attention vector g h and g w Multiply the elements to get the attention calculation result.
[0028] This setting can reduce the complexity of the model while maintaining rich feature expression capabilities before performing attention calculation on the feature map. And when performing attention calculation, the model can focus on the target itself, improving detection efficiency and accuracy.
[0029] Preferably, the prediction head includes multiple detection branches, which correspond to feature maps of specific scales generated by the neck network respectively; when the prediction head is working, for each detection branch, first, a set of small convolutional neural networks are applied at each feature map position to generate corresponding bounding box coordinates, confidence scores and category probabilities; then, according to the pre-set anchor box size, combined with the predicted offset, a candidate bounding box is generated; finally, multiple detection results that may appear for the same target are post-processed, the bounding box with the highest score is retained, and other boxes with too high overlap are removed.
[0030] Preferably, in S2, the preprocessing includes mosaic data enhancement, adaptive image scaling and dynamic anchor point calculation; wherein, mosaic data enhancement is used to enhance background diversity and improve the expressiveness of small targets by randomly cropping, scaling and splicing four images; during adaptive image scaling, the images are unified to a size of 640×640; during adaptive anchor point calculation, the optimal anchor point value is calculated based on different training sets, and then dynamically updated.
[0031] In this way, mosaic data enhancement can enhance background diversity and improve the expressiveness of small objects, thereby effectively improving object detection performance; adaptive image scaling can avoid network input distortion caused by different sizes, so that images can be losslessly fed into the network for processing. Adaptive anchor point calculation enables the object detection model to learn the best anchor box value based on training data.
[0032] Preferably, when constructing the target detection model, the loss function is also optimized, and the optimized loss function Loss is:
[0033] Loss = loss rect +loss obj +L;
[0034] L=W box L box +W cls L cls ;
[0035]
[0036] In the formula, loss rect is the rectangular loss, loss obj is the target existence loss; L is other losses; L box is the bounding box loss; L cls is the classification loss; W box and W cls Represent the weights of bounding box loss and classification loss respectively; L dis is the distance loss of the center point of the border; L shape is the shape loss of the border; IOU is the ratio of the intersection area to the union area of the predicted bounding box and the true bounding box, 1-IOU represents the difference between the intersection area and the union area, and the larger the value, the greater the difference.
[0037] In this way, the loss function is optimized and faster convergence speed and better inference performance can be achieved in the training phase by introducing matching errors.
[0038] Preferably, loss rect and loss obj Use BCEWithLogitsLoss to calculate loss cls Calculations were performed using CIOU.
[0039] Preferably, the distance cost L dis The calculation formula is:
[0040]
[0041]
[0042]
[0043] r=2-L angle ;
[0044] Among them, rρ t Indicates that ρ t Multiply by r; ρt is x or y , represent the normalized distance errors in the x-direction and y-direction respectively; is the coordinate of the center point of the real bounding box; is the coordinate of the center point of the predicted bounding box; c w 、c h is the preset reference width and reference height; L angle is the angle loss.
[0045] With this setup, r is given time priority over the distance value as the angle increases.
[0046] Preferably, the angle loss L angle The calculation formula is:
[0047]
[0048]
[0049]
[0050]
[0051] Where φ is the angle parameter and σ represents the distance between the center of the predicted box and the center of the real box.
[0052] Preferably, the shape loss L shape The calculation formula is:
[0053]
[0054]
[0055]
[0056] Among them, w t w w or h ;w w 、w h Represent the normalization coefficients in the horizontal and vertical directions respectively; o represents the degree of attention to the shape cost; w and h are the width and height of the predicted bounding box respectively; w gt and h gt are the width and height of the ground-truth bounding box, respectively. BRIEF DESCRIPTION OF THE DRAWINGS
[0057] In order to make the purpose, technical solution and advantages of the invention more clear, the present invention will be further described in detail below with reference to the accompanying drawings, in which:
[0058] Figure 1A schematic diagram is provided to illustrate a complex scenario in the background technology;
[0059] Figure 2 A flowchart of the method is shown in FIG.
[0060] Figure 3 Schematic diagram of the architecture of the target detection model in this method. DETAILED DESCRIPTION
[0061] The following is a further detailed description through specific implementation methods:
[0062] Example:
[0063] like Figure 2 As shown, this embodiment discloses a target detection method based on a collaborative attention mechanism multi-scale target detection network, including the following steps:
[0064] S1. Build a target detection model; the target detection model includes a backbone network, a neck network, and a prediction head. And optimize the loss function. The target detection model is as follows Figure 3 shown.
[0065] The backbone network includes an optimized DarkNet-53 model, and the backbone network is used to extract features at different levels from the input image using the optimized DarkNet-53 model.
[0066] In specific implementation, when the backbone network uses the optimized DarkNet-53 model to extract features of different levels from the input image, the process of the downsampling stage includes: for the input image X; first, use a convolution kernel of size 3×3 with a step size of 1 to extract the deep features of the image and generate the initial feature map F(x,y); then, according to the set downsampling factor s, the initial feature map F(x,y) is divided into a series of sub-feature maps f(x,y); finally, these sub-feature maps are spliced along the channel dimension to obtain a new feature mosaic data enhancement map F′. Compared with the use of conventional convolution blocks for downsampling operations, such downsampling operations can effectively avoid the problem of small target feature loss caused by downsampling in the feature extraction stage.
[0067] The neck network is used to further process and integrate the features extracted by the backbone network.
[0068] In order to deeply explore and improve the multi-scale feature fusion capability of the model, the obtained feature map F′ is sent to BiFPN for efficient cross-scale feature fusion. Specifically, in BiFPN, we not only allow information transmission from top to bottom, but also introduce information feedback from bottom to top. This two-way interaction enables the features of each level to receive rich information from the upper and lower layers at the same time. In addition, between each pair of adjacent scales, we use learnable weight coefficients to adjust the importance of features of different scales. These weights are automatically optimized during the training process. At the same time, in order to fully fuse multi-scale features, we designed a multi-level structure in the neck network. Feature fusion is performed once within each level, and then the fused features are input into the next level again for iterative fusion, so as to gradually strengthen the mutual influence between features of different scales and improve the quality of the final fused features.
[0069] Among them, a feature enhancement module based on the collaborative attention mechanism is embedded in the neck network to make the target detection model focus on the target itself. In specific implementation, the related work of the feature enhancement module based on the collaborative attention mechanism in the target detection module includes:
[0070] First, the number of channels of the input feature map is reduced to half through a 1×1 convolution, and then restored to the original value through a 3×3 convolution; then, attention calculation is performed on the feature map;
[0071] The process of attention calculation for the feature map includes: for the feature map F, using the pooling kernels of size H×1 and 1×W along the X and Y axis directions respectively to generate the feature map f x and f y ; Then, use 1×1 convolution to increase the dimension of these features, and combine with Sigmoid activation function to generate attention vector g h and g w ; Finally, by comparing the feature map F with its corresponding attention vector g h and g w The attention calculation result is obtained by element-wise multiplication. The calculation formula is:
[0072] y(i,j)=f(i,j)×g h (i)×g w (j);
[0073] Where f(i,j) is the eigenvalue at position (i,j) in the image.
[0074] This setting can reduce the complexity of the model while maintaining rich feature expression capabilities before performing attention calculation on the feature map. And when performing attention calculation, the model can focus on the target itself, improving detection efficiency and accuracy.
[0075] The collaborative attention mechanism can make the model more flexible to adapt to diverse task requirements without significantly increasing the computational burden. Unlike the traditional two-dimensional global pooling method, the collaborative attention mechanism decomposes the conversion process of the feature tensor into two independent one-dimensional feature encoding processes, which aggregate features along the two spatial directions of the tensor. The resulting feature maps are encoded into a pair of attention maps with direction perception and position sensitivity. These two attention maps can complement each other on the original input feature map, thereby effectively improving the ability to express and distinguish the features of the target object.
[0076] The prediction head is used to process the features output by the neck network and generate the final object detection result.
[0077] In specific implementation, the prediction head contains four detection branches, which correspond to the feature maps of each specific scale generated by the neck network. When the prediction head is working, for each detection branch, first, a set of small convolutional neural networks are applied at each feature map position to generate the corresponding bounding box coordinates, confidence scores and category probabilities. Then, according to the pre-set anchor box size, it is combined with the predicted offset to generate a candidate bounding box. Finally, multiple detection results that may appear for the same target are post-processed, the bounding box with the highest score is retained, and other boxes with too high overlap are removed.
[0078] The loss function Loss after the target detection model is optimized is:
[0079] Loss = loss rect +loss obj +L;
[0080] L=W box L box +W cls L cls ;
[0081]
[0082] In the formula, loss rect is the rectangular loss, loss obj is the target existence loss; L is other losses; L box is the bounding box loss; L cls is the classification loss; W box and W cls Represent the weights of bounding box loss and classification loss respectively; L dis is the distance loss of the center point of the border; L shape is the shape loss of the border; IOU is the ratio of the intersection area to the union area of the predicted bounding box and the true bounding box, 1-IOU represents the difference between the intersection area and the union area, and the larger the value, the greater the difference.
[0083] Among them, loss rect and loss obj Use BCEWithLogitsLoss to calculate loss cls Use CIOU for calculation. BCEWithLogitsLoss stands for Binary Cross Entropy With Logits Loss, which is a commonly used binary classification loss function in PyTorch. Its function is to convert the logits value output by the neural network into a probability and calculate the cross entropy loss between it and the true label. This function combines the Sigmoid layer (used to convert the predicted value into a probability) and the binary cross entropy loss (used to measure the difference between the model prediction and the true label). During the forward and backward propagation process, it can automatically apply the sigmoid activation function and the corresponding gradient, which makes the gradient calculation more efficient and avoids the gradient explosion or gradient vanishing problem of the intermediate activation function. CIOU (Complete Intersection over Union) is an indicator used to measure the degree of overlap between the predicted bounding box and the true bounding box in the target detection task. It is a loss function improved on the traditional IOU (Intersection over Union).
[0084] In this way, the loss function is optimized and faster convergence speed and better inference performance can be achieved in the training phase by introducing matching errors.
[0085] Among them, the distance cost L dis The calculation formula is:
[0086]
[0087]
[0088]
[0089] r=2-L angle ;
[0090] Among them, rρ t Indicates that ρ t Multiply by r; ρ t is x or y , represent the normalized distance errors in the x-direction and y-direction respectively; is the coordinate of the center point of the real bounding box; is the coordinate of the center point of the predicted bounding box; c w 、c h is the preset reference width and reference height; L angleis the angle loss. It can be seen that for the angle parameter φ, when φ→0, the contribution of the distance cost is greatly reduced. On the contrary, when The greater the distance cost contribution is, the greater the angle is. Therefore, as the angle increases, r is given time priority over the distance value.
[0091] Angle loss L angle The calculation formula is:
[0092]
[0093]
[0094]
[0095]
[0096] Where φ is the angle parameter and σ represents the distance between the center of the predicted box and the center of the real box.
[0097] Shape loss L shape The calculation formula is:
[0098]
[0099]
[0100]
[0101] Among them, w t w w or h ;w w 、w h Represent the normalization coefficients in the horizontal and vertical directions respectively; o represents the degree of attention to the shape cost; w and h are the width and height of the predicted bounding box respectively; w gt and h gt are the width and height of the ground-truth bounding box, respectively.
[0102] S2. Obtain image data and perform preprocessing to obtain a training data set for the target detection model.
[0103] The preprocessing includes mosaic data enhancement, adaptive image scaling and dynamic dynamic anchor point calculation; wherein, mosaic data enhancement is used to enhance background diversity and improve the expressiveness of small targets by randomly cropping, scaling and splicing four images; during adaptive image scaling, the images are unified to 640×640 size; during adaptive anchor point calculation, the optimal anchor point value is calculated based on different training sets and dynamically updated accordingly. In this way, through mosaic data enhancement, the background diversity can be enhanced and the expressiveness of small targets can be improved, thereby effectively improving the target detection performance; through adaptive image scaling, the network input distortion problem caused by different sizes can be avoided, so that the image can be losslessly sent to the network for processing. And the adaptive anchor point calculation enables the target detection model to learn the optimal anchor box value based on the training data.
[0104] In specific implementation, the image preprocessing process includes:
[0105] First, the input image is scaled to 640×640 size and padding is added on the top and bottom to maintain the aspect ratio.
[0106] Next, the pixel values of the image are normalized to [0, 1] by dividing them by 255, and the image data is enhanced by methods such as rotation, flipping, cropping, brightness and contrast adjustment.
[0107] Then, add a batch dimension to the image so that its shape changes from (640,640,3) to (1,640,640,3).
[0108] Finally, the labels are converted to coordinates relative to the image size, the category labels are converted to corresponding integers, and the preprocessed images and labels are packaged into a dataset.
[0109] When acquiring image data, you can download the currently public VisDrone2019 and UAVDT. The VisDrone2019 dataset consists of 10,209 high-resolution images, each with a resolution of 2000×1500 pixels, and a total of 10 different categories of targets. These images are taken by cameras installed on a variety of drones, covering a wide range of location attributes, environmental conditions, object types, and scene densities. There are 6,471 images for training, 548 images for verification, and 3,190 images for testing. In addition, the UAVDT dataset contains 100 video sequences, a total of approximately 80,000 frames of images, with an average resolution of approximately 1080×540 pixels per frame, covering a wide range of scene types, and including various types of vehicles as target objects, such as cars, buses, and trucks.
[0110] S3. Use the training data set obtained in S2 to train the target detection model.
[0111] In specific implementation, Sun Lianhao's target detection model can be deployed in the system environment where it needs to be used, and a deep learning environment can be built using Python language and deep learning libraries such as Pytorch. Specifically, the Python language version can use the newer 3.8.2 version, and Pytorch 1.12.0 is used as a dependent library for implementing deep learning algorithms.
[0112] First, the hardware part of the image text retrieval model is deployed. In this embodiment, the computer device used in the hardware part is a server computer based on an AMD processor and an NVIDIA GeForce GTX 1080Ti GPU, and the required image and text data can be transmitted to its storage system through the network.
[0113] Then, deploy the software part of the image text retrieval model. Integrate the trained object detection model and the corresponding Web system or GUI software to form an image text retrieval system. Since the code is implemented in Python and does not easily use third-party libraries that are difficult to cross-platform, the code can be easily compiled to run on the server.
[0114] S4. Use the trained target detection model to perform actual target detection.
[0115] In specific implementation, the image to be detected can be uploaded through the interface on the web page. The background model performs image processing and detection and returns the corresponding results, which are also returned to the front-end system for display.
[0116] In the target detection model constructed by this method, the backbone network uses the optimized DarkNet-53 model to extract features at different levels of the output image. Compared with the use of conventional convolution blocks for downsampling operations, the downsampling of the DarkNet-53 model is mainly achieved through convolution and pooling operations, which can reduce the size of the feature map while retaining important feature information. In this way, the target detection model can retain the tiny targets or fine structural features of the target in the image during the downsampling process, and can capture enough detail information in the subsequent recognition process. The problem of small target feature loss caused by downsampling in the feature extraction stage is effectively avoided. In addition, the neck network introduces a feature enhancement module based on the collaborative attention mechanism, which can effectively suppress redundant background information without significantly increasing the computational cost, so that the model can focus more on the target itself and improve the detection accuracy. This multi-scale target detection system based on the collaborative attention mechanism can effectively solve the problem of interference from background information. Even when the target size is small or the contrast is low, the background features will not be overly focused during the learning process, which can ensure the learning and distinction of target features, thereby ensuring the detection accuracy and reasoning speed of the model for the target in the reasoning stage. Furthermore, when constructing the target detection model, this method optimizes the loss function and introduces matching errors to achieve faster convergence speed and better reasoning performance in the training phase.
[0117] This method uses lossless downsampling to fully retain the fine-grained information in the image, and uses the attention mechanism to fully mine and integrate multi-level features, thereby achieving high-precision detection of multi-category targets in complex scenes.
[0118] Finally, it should be noted that the above embodiments are only used to illustrate the technical solution of the present invention rather than to limit the technical solution. Those skilled in the art should understand that those modifications or equivalent substitutions of the technical solution of the present invention that do not depart from the purpose and scope of the technical solution should be included in the scope of the claims of the present invention.
Claims
1. A target detection method based on a multi-scale target detection network with a collaborative attention mechanism, characterized in that: The following steps are involved: S1. Build a target detection model; the target detection model includes a backbone network, a neck network, and a prediction head; The backbone network includes an optimized DarkNet-53 model, and the backbone network is used to extract features of different levels from the input image using the optimized DarkNet-53 model; The neck network is used to further process and integrate the features extracted by the backbone network. A feature enhancement module based on the collaborative attention mechanism is embedded in the neck network to enable the target detection model to focus on the target itself. The prediction head is used to process the features output by the neck network and generate the final target detection result; S2, acquiring image data and preprocessing it to obtain a training data set for the target detection model; S3, use the training data set obtained in S2 to train the target detection model; S4. Use the trained target detection model to perform actual target detection.
2. The target detection method based on the collaborative attention mechanism multi-scale target detection network according to claim 1, characterized in that: When the backbone network uses the optimized DarkNet-53 model to extract features of different levels from the input image, the process of the downsampling stage includes: for the input image X; first, use a convolution kernel of size 3×3 with a step size of 1 to extract the deep features of the image and generate the initial feature map F(x,y); then, according to the set downsampling factor s, the initial feature map F(x,y) is divided into a series of sub-feature maps f(x,y); finally, these sub-feature maps are spliced along the channel dimension to obtain a new feature mosaic data enhancement map F ′ .
3. The target detection method based on the collaborative attention mechanism multi-scale target detection network according to claim 1, characterized in that: In the object detection module, the related work of the feature enhancement module based on the collaborative attention mechanism includes: First, the number of channels of the input feature map is reduced to half through a 1×1 convolution, and then restored to the original value through a 3×3 convolution; then, attention calculation is performed on the feature map; The process of attention calculation for the feature map includes: for the feature map F, using the pooling kernels of size H×1 and 1×W along the X and Y axis directions respectively to generate the feature map f x and f y ; Then, use 1×1 convolution to increase the dimension of these features, and combine with Sigmoid activation function to generate attention vector g h and g w ; Finally, by comparing the feature map F with its corresponding attention vector g h and g w Multiply the elements to get the attention calculation result.
4. The target detection method based on the collaborative attention mechanism multi-scale target detection network according to claim 1, characterized in that: The prediction head contains multiple detection branches, which correspond to the feature maps of each specific scale generated by the neck network. When the prediction head is working, for each detection branch, first, a set of small convolutional neural networks are applied at each feature map position to generate the corresponding bounding box coordinates, confidence scores, and category probabilities. Then, according to the pre-set anchor box size, it is combined with the predicted offset to generate a candidate bounding box. Finally, multiple detection results that may appear for the same target are post-processed, the bounding box with the highest score is retained, and other boxes with too high overlap are removed.
5. The target detection method based on the collaborative attention mechanism multi-scale target detection network according to claim 1, characterized in that: In S2, the preprocessing includes mosaic data enhancement, adaptive image scaling and dynamic anchor point calculation; wherein, mosaic data enhancement is used to enhance background diversity and improve the expressiveness of small targets by randomly cropping, scaling and splicing four images; during adaptive image scaling, the image is unified to a size of 640×640; during adaptive anchor point calculation, the optimal anchor point value is calculated based on different training sets and dynamically updated accordingly.
6. The target detection method based on the collaborative attention mechanism multi-scale target detection network according to claim 1, characterized in that: When building the target detection model, the loss function is also optimized. The optimized loss function Loss is: Loss=loss rect +loss obj +L; L=W box L box +W cls L cls ; In the formula, loss rect is the rectangular loss, loss obj is the target existence loss; L is the mixed loss; L box is the bounding box loss; L cls is the classification loss; W box and W cls Represent the weights of the border loss and classification loss respectively; Lg dis is the distance loss of the center point of the border; L shape is the shape loss of the border; IOU is the ratio of the intersection area to the union area of the predicted bounding box and the true bounding box, 1-IOU represents the difference between the intersection area and the union area, and the larger the value, the greater the difference.
7. The target detection method based on the collaborative attention mechanism multi-scale target detection network according to claim 6, characterized in that: loss rect and loss obj Use BCEWithLogitsLoss to calculate loss cls Calculations were performed using CIOU.
8. The target detection method based on the collaborative attention mechanism multi-scale target detection network according to claim 7, characterized in that: Distance cost L dis The calculation formula is: r=2-L angle ; Among them, ρ x , y Represent the normalized distance error in the x-direction and y-direction respectively; is the coordinate of the center point of the real bounding box; is the coordinate of the center point of the predicted bounding box; c w 、c h is the preset reference width and reference height; L angle is the angle loss.
9. The target detection method based on the collaborative attention mechanism multi-scale target detection network according to claim 8, characterized in that: Angle loss L angle The calculation formula is: Where φ is the angle parameter and σ represents the distance between the center of the predicted box and the center of the real box.
10. The target detection method based on the collaborative attention mechanism multi-scale target detection network according to claim 9, characterized in that: Shape loss L shape The calculation formula is: Among them, w w 、w h Represent the normalization coefficients in the horizontal and vertical directions respectively; o represents the degree of attention to the shape cost; w and h are the width and height of the predicted bounding box respectively; w gt and h gt are the width and height of the ground-truth bounding box, respectively.
Citation Information
Cited By
Underwater target image detection method and device
CN120032118A
Contact network dropper state detection method based on improved YOLOv11s
CN120451064A
Modeling method suitable for traceability and quality parameter collaborative detection of mineral products
CN121073511A
