Small target detection method and device based on improved YOLOv5s network and medium
By improving the YOLOv5s network and employing techniques such as CMBFF, Adaptive-MSDiFE, and GCRCSA-AFPN, the problems of low accuracy and slow speed in small target detection have been solved, achieving efficient and accurate detection in complex scenarios.
Patent Information
- Application Number
- CN202511098931.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-06
- Publication Date
- 2025-11-21
- Estimated Expiration
- 2045-08-06
AI Technical Summary
Existing technologies suffer from low detection accuracy, slow speed, and poor robustness in small target detection, especially in complex scenarios where it is difficult to effectively capture the key feature information of small targets.
The CSP1_1 module of the YOLOv5s backbone network is replaced by the CMBFF composite multi-branch feature fusion module. The Adaptive-MSDiFE adaptive multi-scale dilated deep feature enhancement mechanism and the BiFormer bidirectional attention mechanism with DSAM dynamic scaling attention factor are introduced into the neck network. The FPN feature fusion module is replaced by GCRCSA-AFPN to enhance feature representation and generalization ability.
It improves the accuracy and precision of small target detection, enhances the model's understanding of local and global context, achieves a balance between accuracy and efficiency, reduces the number of model parameters by 12%, and speeds up detection.
Smart Images

Figure CN120997731A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of target detection technology, particularly to small target personnel detection technology, and more specifically to a small target detection method, device, and medium based on an improved YOLOv5s network. Background Technology
[0002] Target detection based on computer vision is the foundation of complex visual recognition tasks and a prerequisite for completing high-level visual applications such as target tracking and event detection. However, the difficulty lies in the detection of small targets, especially in complex scenarios such as video reconnaissance and video analysis at stations, airports, and roads. The detection of small targets, such as people, faces many challenges, mainly because they occupy a small proportion of pixels in the image or video frame, resulting in low resolution and limited extractable features.
[0003] Small target detection refers to objects with a pixel area smaller than 32*32 pixels, as defined in COCO. Compared to targets of regular size, small targets typically lack sufficient feature information, making it difficult to distinguish them from the background or similar targets. Although deep learning has led to the development of better detection algorithms such as Fast R-CNN, RetinaNet, and YOLO, there is still a significant gap between the performance of small target detection (APS) and large target detection (APL). The performance of small target detection is usually only half that of large target detection. Therefore, achieving fast and efficient small target feature detection is of great significance for assisting law enforcement officers in accurately locating individuals of special concern, tracking key individuals, and uncovering crucial clues.
[0004] The core challenges of small object detection lie primarily in three aspects: First, small objects have insufficient RGB image information, resulting in a limited set of discriminative features. Second, anchor matching is difficult; even slight misalignment between the anchor and the ground box leads to a very low Intersection of Units (IoU), making them easily classified as negative samples by the network. Third, the complexity of real-world scenes, including drastic changes in lighting, occlusion, partial occlusion, blurring, incompleteness, and dense object connectivity, significantly impacts the features of small objects, further increasing the difficulty of detection. To address these challenges, existing algorithms for small object detection in complex scenes have achieved some success by improving feature extraction and network structure in addition to traditional image processing methods. For example, manually extracting pedestrian representation information using Haar wavelet features, HOG gradient orientation histograms, and LBP algorithms can improve the representation of small target features. However, these methods suffer from poor real-time performance, weak generalization ability, and poor robustness. Mainstream deep learning image processing algorithms are divided into two-stage and single-stage object detection algorithms. Two-stage object detection algorithms mainly utilize R-CNN, Faster R-CNN series, and their optimized versions such as Mask R-CNN and Libra R-CNN. Single-stage object detection algorithms primarily use SSD and YOLO series. Two-stage object detection algorithms offer high accuracy but are slower; while single-stage algorithms (such as SSD and YOLO series) are faster, their performance in capturing small target features, handling occlusion, and adapting to dense scenes needs improvement. Summary of the Invention
[0005] The purpose of this invention is to provide an improved method for small target detection using the YOLOv5s network. It replaces the first CSP1_1 module in the backbone network with a CMBFF composite multi-branch feature fusion module. Simultaneously, it introduces an Adaptive-MSDiFE adaptive multi-scale dilated depth feature enhancement mechanism and a BiFormer bidirectional attention mechanism (Improved BRA) based on DSAM dynamic scaling attention factor into the neck network. Furthermore, it replaces the original FPN feature fusion module with GCRCSA-AFPN. This improves the ability to extract multi-scale information from images and enhances the model's expressive performance. It also further captures key feature information of small targets. The GCRCSA-AFPN gated residual connection self-attention mechanism (AFPN) replaces the original FPN feature fusion module, enhancing feature representation and generalization ability, and improving the model's understanding of local and global context. Through this optimized YOLOv5s network model, the accuracy and precision of small target detection are improved.
[0006] According to a first aspect of the present invention, an improved method for small target detection using a YOLOv5s network model is proposed, comprising the following steps:
[0007] An improved YOLOv5s network model was constructed, including: replacing the first CSP1_1 module in the YOLOv5s backbone network with a CMBFF composite multi-branch feature fusion module; using a BiFormer bidirectional attention mechanism based on Adaptive-MSDiFE adaptive multi-scale dilated deep feature enhancement and DSAF dynamic scaling attention factor in the neck network; and replacing the original FPN feature fusion module with a GCRCSA-AFPN gated residual connection self-attention mechanism in the feature fusion module.
[0008] The improved YOLOv5s network model was trained using a road scene analysis dataset as a small object detection model; and
[0009] Images collected in real-world scenarios are input into a trained small object detection model, which outputs small object pedestrian detection results.
[0010] According to a second aspect of the present invention, a small target detection device based on an improved YOLOv5s network is also proposed, comprising:
[0011] The YOLOv5s network model building module is configured to build an improved YOLOv5s network model, including: replacing the first CSP1_1 module in the YOLOv5s backbone network with a CMBFF composite multi-branch feature fusion module; using a BiFormer bidirectional attention mechanism based on Adaptive-MSDiFE adaptive multi-scale dilated deep feature enhancement and DSAF dynamic scaling attention factor in the neck network; and replacing the original FPN feature fusion module with a GCRCSA-AFPN gated residual connection self-attention mechanism in the feature fusion module.
[0012] The model training module is configured to train the improved YOLOv5s network model as a small object detection model using a road scene dataset; and
[0013] The small object detection module is used to input images collected in real-world scenarios into a trained small object detection model and output small object pedestrian detection results.
[0014] The small target detection method based on the improved YOLOv5s network in the above embodiments of the present invention replaces the first CSP1_1 module in the YOLOv5s backbone network with a CMBFF (Composite Multi-Branch Feature Fusion Module). Feature fusion is achieved through multi-branch convolution operations and residual connections, fusing features at different scales to improve the model's expressive power and more effectively capture multi-scale information in the image. In the neck network, an Adaptive-MSDiFE (Adaptive Multi-Scale Dilation Feature Enhancement) adaptive multi-scale dilation depth feature enhancement mechanism and a bidirectional attention mechanism with DSAM dynamic scaling attention factor are designed based on BiFormer BRA (Bi-Level Routing Attention). This better captures key features of small targets, effectively improving the ability to capture global key information and preserve local details, further improving the model's detection accuracy and accelerating inference speed. Furthermore, the GCRCSA-AFPN (Gate Control Residual Connection Self-Attention) mechanism is designed. The AFPN gated residual connection self-attention mechanism replaces the original FPN feature fusion module, enhancing feature representation and generalization ability, improving the model's understanding of local and global contexts, and improving the accuracy of small target detection in complex backgrounds such as three stations and one field.
[0015] The small object detection method proposed in this invention, based on an improved YOLOv5s network, achieves a small object detection mAP@0.5 of 78.3% on public datasets (such as VisDrone), which is 9.1% higher than the YOLOv5s baseline, while reducing the number of model parameters by 12%, thus achieving a balance between accuracy and efficiency.
[0016] It should be understood that all combinations of the foregoing concepts and the additional concepts described in more detail below may be considered part of the inventive subject matter of this disclosure, provided that such concepts do not contradict each other. Furthermore, all combinations of the claimed subject matter are considered part of the inventive subject matter of this disclosure.
[0017] The foregoing and other aspects, embodiments, and features of the teachings of the present invention will be more fully understood from the following description in conjunction with the accompanying drawings. Other additional aspects of the invention, such as features and / or beneficial effects of exemplary embodiments, will become apparent from the following description or may be learned through practice of specific embodiments according to the teachings of the present invention. Attached Figure Description
[0018] The accompanying drawings are not intended to be drawn to scale. In the drawings, each identical or nearly identical component shown in the various figures may be denoted by the same reference numeral. For clarity, not every component is labeled in each figure. Embodiments of various aspects of the invention will now be described by way of example and with reference to the accompanying drawings.
[0019] Figure 1 This is a flowchart illustrating a small target detection method based on an improved YOLOv5s network according to an embodiment of the present invention.
[0020] Figure 2 This is a schematic diagram of an improved YOLOv5s network model according to an embodiment of the present invention.
[0021] Figure 3 This is a schematic diagram of the CMBFF composite multi-branch feature fusion module according to an embodiment of the present invention.
[0022] Figure 4 This is a schematic diagram of an Improved BRA according to an embodiment of the present invention.
[0023] Figure 5 This is a schematic diagram of the processing flow of Improved BRA according to an embodiment of the present invention.
[0024] Figure 6 This is a schematic diagram of the GCRCSA-AFPN feature fusion module according to an embodiment of the present invention.
[0025] Figure 7 , Figure 8 , Figure 9 , Figure 10 , Figure 11 , Figure 12 The images show the detection results of existing technologies such as Faster R-CNN, YOLOv4-tiny, YoLov5n, YoLov5s, YoLov5s-C2f, and the algorithm of this invention on an authoritative dataset of road scenes. Detailed Implementation
[0026] To better understand the technical content of the present invention, specific embodiments are described below in conjunction with the accompanying drawings.
[0027] Various aspects of the invention are described in this disclosure with reference to the accompanying drawings, which illustrate numerous illustrative embodiments. The embodiments of this disclosure are not necessarily intended to encompass all aspects of the invention. It should be understood that the various concepts and embodiments described above, as well as those described in more detail below, can be implemented in any of many ways, because the concepts and embodiments disclosed herein are not limited to any particular implementation. Furthermore, some aspects of the invention disclosed may be used alone or in any suitable combination with other aspects of the invention disclosed.
[0028] {Example 1}
[0029] According to embodiments of the present invention, a small target detection method based on an improved YOLOv5s network is optimized using the YOLOv5s network model as the detection model. On the one hand, the CMBFF composite multi-branch feature fusion module is used to replace the first CSP1_1 module in the backbone network for backbone feature extraction. Feature fusion is achieved through multi-branch convolution operations and residual connections, which fuses features at different scales to improve the model's expressive power and can more effectively capture multi-scale information in the image. On the other hand, in the neck network (used for neck feature extraction), an Adaptive-MSDiFE adaptive multi-scale dilated depth feature enhancement mechanism and a BiFormer bidirectional attention mechanism (ImprovedBRA) with DSAF dynamic scaling attention factor are designed and introduced to fuse feature maps with GCRCSA-AFPN, which strengthens key region features. A Top-k routing strategy is introduced to reduce redundant computation. By dynamically weighting features based on a gating mechanism and utilizing self-attention, the ability to recognize occluded targets is enhanced. Residual connections preserve original details, significantly optimizing the accuracy and robustness of small target detection in complex scenes.
[0030] Combination Figures 1-6 As shown, a small target detection method based on an improved YOLOv5s network, as an example, includes the following steps:
[0031] An improved YOLOv5s network model was constructed, including: replacing the first CSP1_1 module in the YOLOv5s backbone network with a CMBFF composite multi-branch feature fusion module; using a BiFormer bidirectional attention mechanism based on Adaptive-MSDiFE adaptive multi-scale dilated deep feature enhancement and DSAF dynamic scaling attention factor in the neck network; and replacing the original FPN feature fusion module with a GCRCSA-AFPN gated residual connection self-attention mechanism in the feature fusion module.
[0032] The improved YOLOv5s network model was trained using a road scene analysis dataset as a small object detection model; and
[0033] Images collected in real-world scenarios are input into a trained small object detection model, which outputs small object pedestrian detection results.
[0034] As an optional embodiment, combined with Figure 2 , 3 As shown, the structure of the CMBFF (Composite Multi-Branch Feature Fusion Module) includes:
[0035] For an input feature F in First, a 3x3 convolution kernel is used to process the input features F. in Convolution operations are performed, followed by batch normalization (BN) and ReLU activation to obtain intermediate feature T1. Next, a 5x5 convolution kernel is used to convolve the same input features, again followed by BN and ReLU activation to obtain another set of features T2. Then, a 3x3 convolution kernel is used to fuse the features of T1 and T2, again followed by BN and ReLU activation to obtain fused feature T3. Next, a 5x5 convolution kernel is used to fuse T1 and T2, resulting in another fused feature T4. Finally, T3 and T4 are further fused using a 1x1 convolution to generate output feature T'.
[0036] The original input features F are connected using a residual connection. in After processing with a 1x1 convolution, the result is added to T' to form the final output F. out And retain the original feature information.
[0037] In embodiments of the present invention, compared to the CSP1_1 module of YOLOv5s, the CMBFF module used in the improved YOLOv5s model of the present invention is a module in a depthwise separable convolutional network. It improves the expressive power of the model by fusing features at different scales. Compared to traditional convolutional layers, the CMBFF module can better capture multi-scale information in images and can also reduce the complexity of the model, thereby achieving better results.
[0038] In an embodiment of the present invention, in the application scenario of small target person detection in complex scenes, based on the BiFormer BRA of this example, a DSAM dynamic scaling attention mechanism and an Adaptive-MSDiFE adaptive multi-scale dilation depth feature enhancement mechanism are introduced to propose an Improved BRA. Compared with traditional attention mechanisms such as Vanilla, Local, Axial, and Dilated, it can better capture key features of small targets, effectively improve the ability to capture global key information and retain local details, further improve the model detection accuracy, accurately filter information irrelevant to the query, effectively save computation and memory overhead, and accelerate inference speed.
[0039] As an example, combined Figure 4 , Figure 5 As shown, the BiFormer bidirectional attention mechanism based on the Adaptive-MSDiFE adaptive multi-scale dilation deep feature enhancement mechanism and the DSAF dynamic scaling attention factor includes the following process:
[0040] Rearrange and automatically fill in the input feature map;
[0041] The padded input feature map is divided into multiple windows;
[0042] Perform a QKV linear transformation on each window to generate a query vector q and a key-value pair kv, and flatten the query vector q and key-value pair kv within the window into a pixel-level representation;
[0043] Calculate the average query vector and key-value pairs for each window, and determine the routing weight and index weight of the top-k related windows using the Routing() function based on the global routing strategy.
[0044] Dynamically filter relevant key-value pairs based on route index and route weight;
[0045] Based on the DSAM dynamic scaling attention mechanism, the scaling factor of each query vector is adaptively adjusted, and the pixel-level representation of the query vector is multiplied by the scaling factor.
[0046] The local representation of the input feature map is enhanced based on the Adaptive-MSDiFE adaptive multi-scale dilation deep feature enhancement mechanism. Multi-scale features are extracted using convolutions with different dilation rates and then sequentially combined and concatenated into the output.
[0047] The multi-scale features based on Adaptive-MSDiFE combined splicing output are fused with the attention results based on DSAM for output.
[0048] As an optional embodiment, for the input feature map x, the input feature map x is rearranged from a (N,H,W,C) shape to a (N,H) shape. padded W padded (,C) and perform automatic filling, the size of the input feature map after filling is (N,H) padded W padded Where N is the batch size of the input images; H is the image height; W is the image width; C is the number of channels; H padded W is the height of the filled image. padded It is the width of the padded image.
[0049] Furthermore, the padded input feature map is segmented into multiple windows, including:
[0050] The padded input feature map x is divided into multiple windows of size (N, n_win^2, h', w', C), where n_win is the window size:
[0051]
[0052] Where h′: the height of each segmented small window image; w′: the width of each segmented small window image.
[0053] Then, using the QKV mapping, a linear transformation is performed on each window according to the following formula to generate a query vector q and key-value pairs kv, which are used to capture global context information:
[0054] q = W q ·x,kv=W kv ·x;
[0055] Among them, W q and W kv That is the corresponding weight matrix.
[0056] Then, the query vector q and key-value pair kv in the window are flattened into pixel-level representations to obtain q_pix and kv_pix.
[0057] In embodiments of the present invention, the local representation of the input feature map x is enhanced by introducing the Adaptive-MSDiFE adaptive multi-scale dilation depth feature enhancement mechanism to capture multi-scale information.
[0058] The input feature map is convolved using convolutional layers with different dilation rates, as shown in the following formula:
[0059] Conv (r) (x)=Conv2d()
[0060] Combine the outputs of all convolutional layers in sequence:
[0061] Adaptive-MSDIFE = Concat(Conv (r0) (x),Conv (r1) (x),Conv (r2) (x))
[0062] Where r0, r1, and r2 represent different expansion rates; Conv (r) The () function represents the dilated convolution operation, x represents the input feature map, and Concat() represents the channel concatenation operation, which enhances the capture of multi-scale details of small targets.
[0063] Furthermore, in an embodiment of the present invention, the average q and k of each window are calculated, a global routing strategy is applied, and the routing weight r_weight and routing index r_idx of the top-k related windows of each window are calculated by the router() function;
[0064] A r =q·k T ;
[0065] I r =r_weight,r_idx=TopkRouting(A r );
[0066] Among them, A r The window attention matrix is represented by the routing weight r_weight, which expresses the association weight between the current window and the selected related windows, further quantifying the degree of dependency between windows. The routing index r_idx records the indices of the top K windows most relevant to the current window selected from all windows.
[0067] Then, dynamic key-value collection is performed. Using r_idx, r_weight, and kv, the kv_gather() function selects relevant key-value pairs from kv_pix to obtain k_pix_sel and v_pix_sel:
[0068] kv_pix_sel=kv_gather(r_idx,r_weight,kv);
[0069] K g V g = k_pix_sel, v_pix_sel;
[0070] k_pix_sel, v_pix_sel=kv_pix_sel.split().
[0071] Where kv_pix represents pixel-level key-value pairs; kv_pix_sel represents the filtered pixel-level key-value pairs; K g =k_pix_sel, representing the filtered pixel-level key features; V g =v_pix_sel represents the filtered pixel-level feature value.
[0072] Among them, kv_gather is the collection function, which filters and weights relevant features from global key-value pairs.
[0073] Combination Figure 2 As shown, in an embodiment of the present invention, based on the DSAM dynamic scaling attention mechanism, the scaling factor of each query vector is adaptively adjusted, and the pixel-level represented query vector is multiplied by the scaling factor, including:
[0074] First, the q_pix of each window is standardized, and its standard deviation std_q_pix is calculated.
[0075] Then, multiply by the dynamic scaling factor by pixels:
[0076]
[0077] Where q_pix represents the query vector in pixel-level representation; std_q_pix is the standard deviation of the query vector in pixel-level representation; q_pix_scaled is the scaling factor of the query vector; ε is the adjustment parameter, with a value of 10. -6 To prevent division by zero.
[0078] Combination Figure 2 As shown, in an embodiment of the present invention, during the neck feature fusion process, the multi-scale features output based on Adaptive-MSDiFE combined splicing are fused with the attention results based on DSAM, including:
[0079] O = Attention(q, K) g V g )+Adaptive-MSDiFE
[0080] Where Attention(q,K) g V g ) represents the attention result based on DSAM, K g V g These represent the filtered key and value, respectively.
[0081] O represents the feature map of the fused output; Attention() is the standard attention calculation function. d k For K g Vg The dimension of the key-value vector.
[0082] This allows for the fusion of global information and local details.
[0083] As an example of the invention, combined with Figure 2 Compared to traditional PANet and NAS-FPN, GCRCSA-AFPN, based on AFPN, integrates gating, residual connections and self-attention mechanisms to achieve feature fusion, output the final feature map, improve the model's understanding of local and global context, and enhance feature representation and generalization ability.
[0084] In this embodiment, combined with Figure 6 As shown, the feature fusion based on the gated residual connection self-attention mechanism GCRCSA-AFPN includes the following process:
[0085] First, feature alignment is performed on the input feature maps to ensure they have the same resolution;
[0086] Then, the feature maps aligned with the features are compressed using 1×1 convolution, and batch normalized to generate weights for each level.
[0087] Then, the gating mechanism is applied to map the weights to dynamic weights between 0 and 1 using the sigmoid function, generating a dynamic weight matrix;
[0088] Next, feature fusion is performed using a dynamic weight matrix. Multi-scale features are aggregated based on dynamic weights, and a self-attention mechanism is introduced to enhance feature representation, thereby obtaining weighted fused features.
[0089] Finally, residual connections are introduced to add the original input to the weighted fused features, and the final feature map is generated through a 3*3 convolutional layer.
[0090] As an optional approach, the feature fusion of GCRCSA-AFPN is implemented as follows:
[0091] First, GCRCSA-AFPN adjusts the input feature maps to ensure they have the same resolution before fusion;
[0092] Then, for the input feature map F in-1 F in-2 F in-3 Perform feature compression and calculate the weight matrix, where F in-1 Representing input features Figure 1 :
[0093] level_1_weight_v=BatchNorm(Conv 1×1 (F in-1 ));
[0094] levels_weight_v=Concat(level_1_weight_v,level_2_weight_v,level_3_weight_v);
[0095] The features of the input feature map x are obtained; multiple feature maps are concatenated using Concat() to obtain the concatenated feature map levels_weight_v; then levels_weight_v is further processed using Concat(). 1×1 Feature extraction and the Softmax() operation yield the weight vector levels_weigth;
[0096] Then, a gating mechanism is applied to generate a dynamic weight matrix:
[0097] gated_weights=sigmoid(levels_weight);
[0098] Next, feature fusion is performed using the dynamic weight matrix gated_weights, and the feature representation is further enhanced through a self-attention mechanism:
[0099]
[0100] Where `gated_weights[n-1:n,:]` represents retrieving the gated weights from the (n-1)th row; F in-n Represents the nth feature map; fused_out_reduced indicates that for F in-1 F in-2 F in-3 The result of weighted fusion of features;
[0101] fused_out_reduced=selfAttention(fused_out_reduced);
[0102] Wherein, selfAttention() represents self-attention enhancement of the input features;
[0103] Then, a residual join is introduced: fused_out_1 = fused_out_reduced + F in-1 ;
[0104] fused_out_1 represents the output characteristics after the residual; fused_out_2 = fused_out_reduced + F in-2;fused_out_3=fused_out_reduced+F in-3 ;
[0105] Finally, the final output feature F is generated through convolutional layers. out-1 F out-2 F out-3 :
[0106] F out-1 =Conv 3×3 (fused_out_1);
[0107] F out-2 =Conv 3×3 (fused_out_2);
[0108] F out-3 =Conv 3×3 (fused_out_3).
[0109] {Example 2}
[0110] In this embodiment, combined with Figure 1 and Figure 2 As shown, a specific example illustrates the implementation process of the small target detection method based on the improved YOLOv5s network in the aforementioned embodiments.
[0111] (1) Input preprocessing
[0112] The detection process begins with the standardization of the input image.
[0113] First, image scaling is performed, scaling input images of any size to the fixed size required by the network (e.g., 640x640) according to their original aspect ratio. In particular, gray borders can be filled on both sides of the short side to avoid distortion and ensure the integrity of the geometric features of human targets at different scales.
[0114] Next, normalization is performed, compressing pixel values from the 0-255 range to the [0,1] or [-1,1] interval to accelerate convergence.
[0115] Finally, the data format is converted from H×W×C (640×640×3) to C×H×W (3×640×640) PyTorch tensor format through channel order conversion.
[0116] The preprocessed standardized data lays the foundation for subsequent feature extraction.
[0117] (2) Backbone feature extraction
[0118] The preprocessed tensor input is used to extract multi-scale features through an improved backbone network.
[0119] The first-layer CSP1_1 module in the YOLOv5s backbone network is replaced with CMBFF (Dual-Branch Feature Fusion Module): a 3×3 convolutional branch captures local details of the human body (such as limb edges), a 5×5 convolutional branch extracts global contour features, and the outputs of the two branches are fused by a 1×1 convolution and superimposed with residual connections. This design significantly enhances the ability to preserve features of small targets. The backbone network ultimately outputs three-scale feature maps: for example, layer P3 (80×80) dominates the detection of small targets (such as pedestrians in the distance), layer P4 (40×40) balances details and semantics, and layer P5 (20×20) focuses on large-scale human targets, forming a multi-level feature representation.
[0120] (3) Neck feature fusion
[0121] The backbone output features are fused through the Improved BRA+GCRCSA-AFPN neck module to enhance key region features. A Top-k routing strategy is introduced to reduce redundant computation. Features are dynamically weighted based on a gating mechanism. Self-attention is used to enhance the ability to identify occluded targets. Residual connections preserve original details and significantly optimize the robustness of human detection in complex scenes.
[0122] (4) Head-Detection
[0123] The head is connected to the neck output of the three-scale enhanced feature maps (P3 / P4 / P5). Each grid cell generates a prediction based on a predefined anchor box: bounding box parameters (t... x ,t y ,t w ,t h The encoding center point offset and width / height scaling factors are used, and the target confidence score (obj) represents the probability of existence. The class probability is activated by the Sigmoid function, where the probability value of the "person" class (c_person) is the basis for determining the human target.
[0124] The improved neck features enable the detection head to more accurately locate and classify small human targets (such as partially occluded individuals in dense crowds) at the P3 layer (80×80).
[0125] (5) Output tensor shape
[0126] The output dimension of the detection head strictly corresponds to the three-scale feature map:
[0127] P3 layer (80×80): 3×15×80×80
[0128] P4 layer (40×40): 3×15×40×40
[0129] P5 layer (20×20): 3×15×20×20
[0130] Where 3 represents 3 optimized anchor boxes per grid cell, and 15 includes 4-dimensional bounding box parameters, 1-dimensional target confidence, and 10-dimensional class probabilities.
[0131] To test the effectiveness of the improved YOLOv5s network small object detection method proposed in this invention, we compared its small object detection results on a public dataset (VisDrone as an example) with those of traditional algorithms. As shown in Table 1, the improved YOLOv5s network small object detection method proposed in this invention, after introducing the CMBFF composite multi-branch feature fusion module, the Improved BRA bidirectional routing self-attention module, and the design of the GCRCSA-AFPN feature fusion module, achieves an accuracy improvement of 10.9%, 8.8%, 8.1%, and 6.6% compared to Faster R-CNN, YOLOv4-tiny, YOLOv5n, and YOLOv5s, respectively, and an improvement of 4.7% compared to YOLOv5s-C2f.
[0132] Meanwhile, judging from the mAP50 and mAP95 metrics, the detection results of the method according to the present invention are higher than those of other traditional algorithms. Compared with the original algorithm YOLOv5s, the mAP is improved by 6.1%.
[0133] Based on the above analysis and results, the small target detection results of the method of the present invention are superior to Faster R-CNN, YOLOv4-tiny, YOLOv5n, YOLOv5s, and YOLOv5s-C2f in terms of accuracy and mAP50.
[0134] like Figure 7 , Figure 8 , Figure 9 , Figure 10 , Figure 11 , Figure 12 The diagram shows a comparison of the detection performance of existing technologies such as Faster R-CNN, YOLOv4-tiny, YoLov5n, YoLov5s, YoLov5s-C2f, and the algorithm of this invention on an authoritative dataset of road scenes.
[0135] Table 1 Comparison of mAP (0.5, 0.95) for different algorithms
[0136]
[0137] {Example 3}
[0138] In conjunction with the methods of the above embodiments, the present invention also proposes a small target detection device based on an improved YOLOv5s network, which includes:
[0139] The YOLOv5s network model building module is configured to build an improved YOLOv5s network model, including: replacing the first CSP1_1 module in the YOLOv5s backbone network with a CMBFF composite multi-branch feature fusion module; using a BiFormer bidirectional attention mechanism based on Adaptive-MSDiFE adaptive multi-scale dilated deep feature enhancement and DSAF dynamic scaling attention factor in the neck network; and replacing the original FPN feature fusion module with a GCRCSA-AFPN gated residual connection self-attention mechanism in the feature fusion module.
[0140] The model training module is configured to train the improved YOLOv5s network model as a small object detection model using a road scene dataset; and
[0141] The small object detection module is used to input images collected in real-world scenarios into a trained small object detection model and output small object pedestrian detection results.
[0142] While the present invention has been disclosed above with reference to preferred embodiments, it is not intended to limit the invention. Those skilled in the art can make various modifications and refinements without departing from the spirit and scope of the invention. Therefore, the scope of protection of the present invention shall be determined by the claims.
Claims
1. A small target detection method based on an improved YOLOv5s network, characterized in that, include: An improved YOLOv5s network model was constructed, including: replacing the first CSP1_1 module in the YOLOv5s backbone network with a CMBFF composite multi-branch feature fusion module; using a BiFormer bidirectional attention mechanism based on Adaptive-MSDiFE adaptive multi-scale dilated deep feature enhancement and DSAF dynamic scaling attention factor in the neck network; and replacing the original FPN feature fusion module with a GCRCSA-AFPN gated residual connection self-attention mechanism in the feature fusion module. The improved YOLOv5s network model was trained using a road scene dataset as a small object detection model; as well as Images collected in real-world scenarios are input into a trained small object detection model, which outputs small object pedestrian detection results.
2. The small target detection method based on the improved YOLOv5s network according to claim 1, characterized in that, The CMBFF composite multi-branch feature fusion module structure includes: For an input feature F in First, a 3x3 convolution kernel is used to process the input features F. in Convolution operations are performed, followed by batch normalization (BN) and ReLU activation to obtain intermediate feature T1. Next, a 5x5 convolution kernel is used to convolve the same input features, again followed by BN and ReLU activation to obtain another set of features T2. Then, a 3x3 convolution kernel is used to fuse the features of T1 and T2, again followed by BN and ReLU activation to obtain fused feature T3. Next, a 5x5 convolution kernel is used to fuse T1 and T2, resulting in another fused feature T4. Finally, T3 and T4 are further fused using a 1x1 convolution to generate output feature T'. The original input features F are connected using a residual connection. in After processing with a 1x1 convolution, the result is added to T' to form the final output F. out And retain the original feature information.
3. The small target detection method based on the improved YOLOv5s network according to claim 1, characterized in that, The BiFormer bidirectional attention mechanism based on the Adaptive-MSDiFE adaptive multi-scale dilated depth feature enhancement mechanism and the DSAF dynamic scaling attention factor is used to capture global key information and preserve local details. The process includes: Rearrange and automatically fill in the input feature map; The padded input feature map is divided into multiple windows; Perform a QKV linear transformation on each window to generate a query vector q and a key-value pair kv, and flatten the query vector q and key-value pair kv within the window into a pixel-level representation; Calculate the average query vector and key-value pairs for each window, and determine the routing weight and index weight of the top-k related windows using the Routing() function based on the global routing strategy. Dynamically filter relevant key-value pairs based on route index and route weight; Based on the DSAM dynamic scaling attention mechanism, the scaling factor of each query vector is adaptively adjusted, and the pixel-level representation of the query vector is multiplied by the scaling factor. The local representation of the input feature map is enhanced by an adaptive multi-scale dilation depth feature enhancement mechanism based on Adaptive-MSDiFE. Multi-scale features are extracted by convolution with different dilation rates and sequentially combined and concatenated for output. The multi-scale features based on Adaptive-MSDiFE combined and concatenated output are fused with the attention results based on DSAM for output.
4. The small target detection method based on the improved YOLOv5s network according to claim 3, characterized in that, The DSAM-based dynamic scaling attention mechanism adaptively adjusts the scaling factor for each query vector, multiplying the pixel-level representation of the query vector by the scaling factor, including: First, the q_pix of each window is standardized, and its standard deviation std_q_pix is calculated. Then, multiply by the dynamic scaling factor by pixels: Where q_pix represents the pixel-level representation of the query vector q obtained based on the QKV linear transformation, q_pix_scaled represents the adaptive scaling result of q_pix, and ε represents the adjustment parameter with a value of 10. -6 .
5. The small target detection method based on the improved YOLOv5s network according to claim 3, characterized in that, The adaptive-MSDiFE-based multi-scale dilation depth feature enhancement mechanism enhances the local representation of the input feature map, extracts multi-scale features using convolutions with different dilation rates, and sequentially combines and concatenates the output, including: Convolutional operations are performed on the input feature map using convolutional layers with different dilation rates, as shown in the following formula: Conv (r) (x)=Conv2d() Combine the outputs of all convolutional layers in sequence: Adaptive-MSDIFE=Concat(Conv (r0) (x),Conv (r1) (x),Conv (r2) (x)) Where r0, r1, and r2 represent different expansion rates; Conv (r) The () function represents the dilated convolution operation, x represents the input feature map, and Concat() represents the channel concatenation operation.
6. The small target detection method based on the improved YOLOv5s network according to claim 4 or 5, characterized in that, The process of fusing multi-scale features based on Adaptive-MSDiFE combined splicing output with attention results based on DSAM includes: O=Attention(q,K g ,V g )+Adaptive-MSDiFE Where Attention(q,K) g V g ) represents the attention result based on DSAM, and O represents the feature map of the fused output.
7. The small target detection method based on the improved YOLOv5s network according to claim 1, characterized in that, The GCRCSA-AFPN mechanism, which integrates gating, residual connections, and self-attention, achieves feature fusion and outputs the final feature map. The process includes the following: First, feature alignment is performed on the input feature maps to ensure they have the same resolution; Then, the feature maps aligned with the features are compressed using 1×1 convolution, and batch normalized to generate weights for each level. Then, the gating mechanism is applied to map the weights to dynamic weights between 0 and 1 using the sigmoid function, generating a dynamic weight matrix; Next, feature fusion is performed using a dynamic weight matrix. Multi-scale features are aggregated based on dynamic weights, and a self-attention mechanism is introduced to enhance feature representation, thereby obtaining weighted fused features. Finally, residual connections are introduced to add the original input to the weighted fused features, and the final feature map is generated through a 3*3 convolutional layer.
8. A computer-readable storage medium for storing one or more programs, said one or more programs comprising instructions or instruction sets executable by one or more processors, characterized in that, When the instructions or instruction set are executed by one or more processors, they perform the process of the small target detection method based on the improved YOLOv5s network as described in any one of claims 1-7.
9. A small target detection device based on an improved YOLOv5s network, characterized in that, include: The YOLOv5s network model building module is configured to build an improved YOLOv5s network model, including: replacing the first CSP1_1 module in the YOLOv5s backbone network with a CMBFF composite multi-branch feature fusion module; using a BiFormer bidirectional attention mechanism based on Adaptive-MSDiFE adaptive multi-scale dilated deep feature enhancement and DSAF dynamic scaling attention factor in the neck network; and replacing the original FPN feature fusion module with a GCRCSA-AFPN gated residual connection self-attention mechanism in the feature fusion module. The model training module is configured to train the improved YOLOv5s network model as a small object detection model using a road scene dataset; and The small object detection module is used to input images collected in real-world scenarios into a trained small object detection model and output small object pedestrian detection results.
Citation Information
Patent Citations
Target detection method for view angle of unmanned aerial vehicle
CN119048730A
Small target detection method and system
CN119516173A
Expression recognition method based on attention-modulated contextual spatial information
WO2023185243A1
Real-time semantic segmentation method combining hierarchical decoding and multi-branch structures
WO2025043912A1
Cited By
Target detection-tracking integrated method and system based on AFPN and LSK-Net
CN121661565A