Target detection method and system in complex environment and medium

Through the improved YOLOV8 structure, combined with coordinate attention and BiFPN, the difficulty in feature extraction of intensive small object detection tasks in complex environments is solved, and higher detection accuracy and generalization capabilities are achieved.

CN119399449APending Publication Date: 2025-02-07GUANGDONG OCEAN UNIVERSITY +1

Patent Information

Application Number
CN202411833586.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-13
Publication Date
2025-02-07

AI Technical Summary

Technical Problem

In complex environments, especially in aerial images of drones, it is difficult to achieve high accuracy for dense small target detection tasks, mainly because the targets are small, dense and easily obstructed by the background, resulting in difficulty in feature extraction.

Method used

The improved YOLOV8 structure is adopted, combining coordinate attention and weighted bidirectional feature pyramid BiFPN, to enhance the model's detection ability of small targets. Specific measures include adding a small target P2 detection layer to the network, fusing multi-scale features through BiFPN, and introducing coordinate attention and RT-DETR decoders in YOLOv8 to improve the acquisition of target position information.

Benefits of technology

It significantly improves the detection accuracy of dense small targets in complex environments, enhances the generalization ability of the model and the perception of high-density targets, and can more effectively suppress the interference of background information.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119399449A_ABST
    Figure CN119399449A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of target recognition, in particular to a target detection method and system in a complex environment and a medium. The method comprises the following steps: acquiring an unmanned aerial vehicle aerial image of a target area; and inputting the aerial image into a trained target detection model, and detecting an area in which a target to be detected exists in the aerial image, the target detection model being based on an improved YOLOV8 structure. The method is used for acquiring spatial position information of targets based on coordinate attention capture and cross-level fusion of multi-scale features and based on attention so as to detect dense small targets. According to the method, the target detection capability of dense small targets in a complex environment can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of target recognition technology, and in particular to a target detection method, system and medium in a complex environment. Background Art

[0002] China is one of the world's major pineapple producing countries. Currently, pineapple harvesting and per-acre yield statistics mainly rely on manual picking and statistics, which requires huge manpower and time costs. The object detection method based on deep learning can automatically identify and count pineapples in image data, thus greatly improving statistical efficiency.

[0003] Drones are popular in the market due to their relatively low cost and ease of operation to quickly capture images in a simple manner. The high spatial resolution images based on drones and their ability to visit multiple times enable the creation of large and detailed datasets. Therefore, pineapple recognition based on drone aerial images has become a research hotspot.

[0004] Due to the characteristics of drone shooting, the pineapple targets in the aerial images are relatively small, and the mainstream deep learning-based neural network design pays little attention to small targets. At the same time, due to the characteristics of pineapple planting, the pineapples in the acquired images are relatively dense, and there are pineapple fruits that are blocked by pineapple leaves and have different postures from other pineapple fruits, which makes feature extraction difficult. The task of identifying pineapples in drone aerial images is a typical target detection task for dense small targets in complex environments, which is difficult to handle with existing deep learning-based target detection algorithms. Summary of the invention

[0005] In view of this, an object of the embodiments of the present invention is to provide a method, an apparatus and a computer-readable storage medium for target detection in a complex environment, so as to improve the target detection capability of densely packed small targets in a complex environment.

[0006] In a first aspect, an embodiment of the present invention provides a method for detecting a target in a complex environment, comprising:

[0007] Acquire drone aerial images of the target area;

[0008] The aerial image is input into a trained target detection model to detect areas in the aerial image where targets to be detected exist, wherein the target detection model is based on an improved YOLOV8 structure, which is used to capture multi-scale features based on coordinate attention and fuse them across levels, and to obtain the spatial position information of the target based on attention, so as to detect dense small targets.

[0009] Optionally, the backbone network of the improved YOLOV8 structure is a weighted bidirectional feature pyramid structure based on coordinate attention and including a small target P2 detection layer, with an RT-DETR decoder as the detection head.

[0010] Optionally, the training method of the target detection model includes:

[0011] In the drone aerial image, manually marking the area where the target to be detected exists to generate a labeled data set;

[0012] Selecting the aerial image as a sample from the data set with labels, training the improved YOLOV8 structure based on the sample and the label to generate the target detection model;

[0013] Among them, the classification loss calculation formula for training the improved YOLOV8 structure is as follows:

[0014]

[0015] Among them, VFL(p,q) represents the classification loss, p is the predicted IoU-aware classification score; q is the target score, γ is the weight, and α1 is the weight of the positive sample;

[0016] The binary cross entropy loss is used when training the improved YOLOV8 structure. The calculation formula of the binary cross entropy loss is as follows:

[0017]

[0018] l n =y n *logx n +(1-y n )*log(1-x n );

[0019] Among them, Loss represents the binary cross entropy loss, N is the number of groups of objects predicted by the model, n is the number of objects predicted by the model, and y n is the nth binary label 0 or 1, x n is the probability that the nth output belongs to the label;

[0020] The regression loss for training the improved YOLOV8 structure includes a first regression loss and a second regression loss;

[0021] The formula for the first regression loss is as follows:

[0022] DFL(S i ,S i+1 )=-((y i+1 -y)log(Si )+(yy i )log(S i+1 ));

[0023] in,

[0024]

[0025] Among them, DFL(S i ,S i+1 ) represents the first regression loss, y is the target true label value, i is the parameter value for distinguishing the left and right distributions of the current predicted target, and y i+1 is the right distribution value of the currently predicted target box, y i is the left distribution value of the currently predicted target box, S i S is the ratio of the difference between the right distribution and the center distribution of the predicted target box to the difference between the left and right distributions. i+1 is the ratio of the difference between the center distribution and the left distribution to the difference between the left and right distributions;

[0026] The calculation formula for the second regression loss is as follows:

[0027] Loss CIoU = 1-CIoU;

[0028]

[0029] Among them, Loss CIoU represents the second regression loss, IoU represents the intersection-over-union ratio between the predicted box and the true box, ρ 2 (B,B gt ) represents the Euclidean distance between the predicted box and the true box, B is the predicted target box, and B gt is the actual target box, α2 is a balance parameter and does not participate in the gradient calculation, c represents the diagonal distance of the minimum closure area that can contain both the predicted box and the real box, v represents the aspect ratio of the predicted box to the real box, and w gt ,h gt is the width and height of the real target box; w, h are the width and height of the predicted target box. When the predicted box is the same length and width as the real box, v is 0.

[0030] Optionally, the backbone network includes multiple convolution modules and c2f modules, and the c2f module contains a skip layer connection for performing feature conversion on input data.

[0031] Optionally, the coordinate-based attention includes:

[0032] The input features are globally pooled along the horizontal and vertical directions and encoded into attention maps containing long-range dependencies along the directions respectively;

[0033] Multiply the two attention maps together and apply them to the mapping of the input features.

[0034] Optionally, the p3 layer of the weighted bidirectional feature pyramid is:

[0035]

[0036] in, is the intermediate feature of level 3 on the top-down path, is the third-layer feature extracted from the backbone, is the output feature of level 4 on the bottom-up path, is the 4th layer feature extracted from the backbone, is the output feature of the fifth level on the bottom-up path, ω1 and ω1', ω2 and ω'2, ω3' are the weights of the corresponding feature maps, and ε is a constant.

[0037] Optionally, the acquisition of spatial position information of the target based on attention includes:

[0038] RT-DETR contains an encoder-decoder structure, where the encoder converts multi-scale features into image feature sequences through intra-scale feature interaction attention and cross-scale feature fusion modules;

[0039] The decoder adopts IoU-aware query selection, selecting a preset number of image features as the initial object query for the encoder to enable the model to focus on the most relevant objects in the scene.

[0040] Optionally, the decoder adopts IoU-aware query selection including:

[0041] The decoder enables each query to take into account information from other queries through a self-attention mechanism, and allows object queries to interact with the encoder’s feature maps through a cross-attention mechanism.

[0042] In a second aspect, an embodiment of the present invention provides a target detection system in a complex environment, including a memory and a processor.

[0043] The memory is used to store computer programs;

[0044] The processor is used to implement the method according to the first aspect of the present invention when executing the computer program.

[0045] According to a third aspect, an embodiment of the present invention provides a computer-readable storage medium storing a program executable by a processor, wherein the executable program is used to execute the method according to the first aspect of the present invention when executed by the processor.

[0046] The embodiments of the present invention include the following beneficial effects: in view of the problem that targets are dense and feature extraction is difficult, the embodiments of the present invention add a small target P2 detection layer to the network to capture target information at different scales and improve the accuracy of small target detection; in view of the problem of feature information loss caused by continuous convolution, the embodiments of the present invention fuse deep semantic information and shallow position information through a weighted bidirectional feature pyramid BiFPN to improve the generalization ability of the model, so that the network can effectively capture multi-scale features and improve the perception ability of high-density targets; in view of the situation that the pineapple leaves in the background are similar in color to the pineapple leaf crown and there are pineapple leaves blocking the pineapple fruit; the embodiments of the present invention introduce coordinate attention ( CoordinateAttention) is used to enhance YOLOv8's attention to the key feature information of the pineapple small target, suppress the interference of invalid background information, and enhance the feature extraction capability of the small target in the detection network; in order to improve the detection accuracy of the model for small targets in complex backgrounds, the embodiment of the present invention introduces the decoder of RT-DETR as the detection head in the original YOLOv8 network, which processes the output features of the encoder through self-attention and cross-attention, obtains the spatial position information of more targets, and improves the model's ability to process overlapping or interrelated targets. BRIEF DESCRIPTION OF THE DRAWINGS

[0047] 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 will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.

[0048] Figure 1 A flowchart of a method for detecting a target in a complex environment provided by an embodiment of the present invention;

[0049] Figure 2 This is a schematic diagram of the structure of the C2f module in the YOLOv8 algorithm;

[0050] Figure 3 It is a schematic diagram of the overall structure of the YOLOv8 algorithm;

[0051] Figure 4 This is a schematic diagram of the BiFPN structure in the improved YOLOv8 algorithm;

[0052] Figure 5 This is a schematic diagram of the structure of coordinate attention in the improved YOLOv8 algorithm;

[0053] Figure 6 It is a schematic diagram of the structure of the Head structure of RT-DETR;

[0054] Figure 7 are some pictures in a training data set used to train a pineapple detection model in an embodiment of the present invention;

[0055] Figure 8 It is a schematic diagram of a target detection system in a complex environment according to an embodiment of the present invention. DETAILED DESCRIPTION

[0056] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0057] It should be noted that all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of this application and are not intended to limit this application.

[0058] The block diagrams shown in the accompanying drawings are merely functional entities and do not necessarily correspond to physically independent entities. That is, these functional entities may be implemented in software form, or in one or more hardware modules or integrated circuits, or in different networks and / or processor devices and / or microcontroller devices.

[0059] The flowcharts shown in the accompanying drawings are only exemplary and do not necessarily include all the contents and operations / steps, nor must they be executed in the order described. For example, some operations / steps can be decomposed, and some operations / steps can be combined or partially combined, so the actual execution order may change according to actual conditions.

[0060] Figure 1 A flowchart of a target detection method in a complex environment provided by an embodiment of the present invention is applied to a target detection server, and the method comprises the following steps:

[0061] S110, obtaining an unmanned aerial vehicle (UAV) aerial image of the target area.

[0062] One embodiment of the present invention identifies pineapples in aerial images of pineapple producing areas during the pineapple picking season. Specifically,

[0063] During the pineapple picking season, drones were used to obtain aerial images of pineapple production areas in Xuwen County, Zhanjiang City, Guangdong Province, China. In this embodiment, the drone equipment is a DJI drone Mavic 3 Pro, the main camera is equipped with a 4 / 3 CMOS sensor, and the resolution of a single image taken is 5472*3078. The drone shooting altitude is between 125m-135m.

[0064] S120, inputting the aerial image into a trained target detection model, and detecting areas in the aerial image where targets to be detected exist, wherein the target detection model is based on an improved YOLOV8 structure, and is used to detect dense small targets by capturing multi-scale features based on coordinate attention and fusing them across levels, and obtaining the spatial position information of the target based on attention.

[0065] First, improve the YOLOV8 structure.

[0066] YOLOv8 object detection algorithm:

[0067] The YOLOv8 target detection algorithm is an algorithm in the YOLO target detection algorithm series developed by the Ultralytics team. This algorithm has the following innovations compared with previous YOLO series algorithms.

[0068] (1) A new network module C2f is proposed. The backbone of YOLOv8 consists of the Conv module and the C2f module. C2f adds more skip layer connections, cancels the convolution operation in the branch, and adds additional split operations. While retaining rich feature information, it reduces the amount of calculation. The C2f structure diagram is shown in the figure below. Figure 2 shown.

[0069] (2) Using the Anchor-free strategy, the difference between Anchor-Based and Anchor-free is whether to use a predefined anchor box to match the real target box. Anchorbox is a set of preset bounding boxes used to offset the position of the predicted box (Prediction box) generated during training relative to the real box (Ground truth box). Its essence is to solve the problem of label assignment. Anchor includes using the points of the feature map extracted by the network to locate the position of the box, and is also used to set the size and shape of the box;

[0070] (3) The classification loss calculation formula of the target detection model is as follows:

[0071]

[0072] Among them, p is the predicted IACS (IoU-aware classification score), which is a soft label related to IoU; q is the target score, γ is the weight, and α1 corresponds to the weight of the positive sample (the class with a small proportion), and its value is generally small. γ is dominant in Focal loss. As γ increases, α1 should decrease accordingly.

[0073] The binary cross entropy loss BCE Loss is used during training. The calculation formula of BCE Loss is as follows:

[0074]

[0075] ln=yn*lo g xn+(1-yn)*lo g (1-xn);

[0076] Among them, Loss represents the binary cross entropy loss, N is the number of groups of objects predicted by the model, n is the number of objects predicted by the model, and y n is the nth binary label 0 or 1, x n is the probability that the nth output belongs to the label;

[0077] The regression loss of the target detection model includes the first regression loss and the second regression loss;

[0078] The formula for the first regression loss is as follows:

[0079] DFL(S i ,S i+1 )=-((y i+1 -y)log(S i )+(yy i )log(S i+1 ));

[0080] in,

[0081]

[0082] Among them, y is the target true label value, i is the parameter value that distinguishes the left and right distributions of the current predicted target, and y i+1 is the right distribution value of the currently predicted target box, y i is the left distribution value of the currently predicted target box, S i S is the ratio of the difference between the right distribution and the center distribution of the predicted target box to the difference between the left and right distributions. i+1 It is the ratio of the difference between the center distribution and the left distribution to the difference between the left and right distributions.

[0083] DFL (Distribution Focal Loss) allows the network to quickly focus on the value near the label, making the probability density at the label as large as possible. The idea is to use the cross entropy function to optimize the probabilities of the two positions near the label, so that the network distribution focuses on the label value.

[0084] The calculation formula for the second regression loss is as follows:

[0085] Loss CIoU= 1-CIoU;

[0086]

[0087] Among them, IoU represents the intersection-over-union ratio between the predicted box and the real box, ρ 2 (B,B gt ) represents the Euclidean distance between the predicted box and the true box, B is the predicted target box, and B gt is the actual target box, α2 is a balance parameter and does not participate in the gradient calculation, c represents the diagonal distance of the minimum closure area that can contain both the predicted box and the real box, v represents the aspect ratio of the predicted box to the real box, and w gt ,h gt is the width and height of the real target box; w, h are the width and height of the predicted target box. When the predicted box is the same length and width as the real box, v is 0.

[0088] (4) The positive sample matching strategy adopts the Task Aligned Assigner allocation strategy. The core idea of ​​this strategy is to select positive samples based on the weighted scores of classification and regression. The formula is: Among them, α3 and β are weight hyperparameters, s is the score of the predicted category, and u is the intersection over union (IoU) of the predicted box and the ground truth box. The two are multiplied to measure the degree of matching. When the classification score is higher and the IoU is higher, the value of t is closer to 1. At this time, the predicted box matches the ground truth box more closely, and the more it meets the standard of positive samples. For each ground truth box, the matching degree is directly sorted, and the topK predicted boxes are selected as positive samples. The matching situation of a predicted box and multiple ground truth boxes is processed, and the ground truth box with the largest IoU value is retained. The YOLOv8 network structure diagram is shown in the figure below. Figure 3 shown.

[0089] Improvements to the YOLOv8 object detection algorithm:

[0090] P2+BifPN: There are three detection heads in the original YOLOv8 network, which are used for small-scale, medium-scale, and large-scale target detection. However, for small target detection objects, small targets themselves have fewer features, and as the convolutional neural network deepens, the feature map is prone to feature loss after the convolution operation. The pineapples in this dataset are taken by drones and the targets are small. The effect of using the original YOLOv8 for training is poor, so it is considered to add a small target detection layer P2 in the YOLOv8 network to enhance YOLOv8's ability to detect pineapples.

[0091] YOLOv8 uses Path Aggregation Network with Feature Pyramid Network (PAN-FPN). Path Aggregation Network (PAN) is designed to enhance feature expression by fusing feature information from different receptive fields, but it cannot effectively handle features at multiple scales. FPN is a feature pyramid network designed specifically for object detection tasks. It performs feature fusion between features at multiple resolution levels to enhance the detection capability of objects of different scales. Traditional FPN uses top-down feature fusion, but this will lose some object location information. In order to alleviate the problems of both, PAN-FPN adds PAN to FPN, and by constructing a bottom-up and top-down network structure, it realizes the feature fusion of shallow location information and deep semantic information in the network, thereby ensuring the diversity and integrity of features.

[0092] BiFPN (Bi-directional Feature Pyramid Network) was proposed by Tan et al. Currently, most target detection models use convolutional neural networks to extract multiple levels of features from input images. Deep networks have a large receptive field and strong ability to represent semantic information, but the feature map resolution is relatively low and spatial features are relatively lacking; shallow networks have a small receptive field and weak ability to express semantic information, but the feature map resolution is large and the feature details are rich. Therefore, the fusion of features at each level can improve the detection capability of the network. In order to solve the problem of insufficient feature fusion in PANet, BiFPN proposed cross-level multi-scale fusion. The calculation formula of the P3 layer is shown below, and the P4 layer is similar:

[0093]

[0094]

[0095] in, is the intermediate feature of level 3 on the top-down path, is the third-layer feature extracted from the backbone, is the output feature of the 4th level on the bottom-up path. ω1 and ω1', ω2 and ω'2, ω3' are the weights of the corresponding feature maps. ε is a constant. All other features are constructed in a similar way. The BiFPN structure is as follows Figure 4 shown.

[0096] Coordinate Attention: The purpose of the attention mechanism in computer vision is to imitate the ability of the human visual system to focus on the salient parts of complex scenes. After the image is input into the model, the attention mechanism will dynamically assign weights according to the importance of the area in the image.

[0097] Coordinate Attention (CA) is a new attention mechanism proposed by Hou et al., which embeds position information into channel attention and is called Coordinate Attention. Coordinate Attention uses two 1D global pooling operations to fuse the input features into two separate directional feature maps in the vertical and horizontal directions respectively. The two feature maps with direction-specific information are then encoded into two maps, each of which captures the long-range dependencies of the input feature map along a spatial direction. The position information is saved in the generated map, and the two attention maps are multiplied and applied to the input feature map. The structural diagram of Coordinate Attention is shown in the figure below. Figure 5 shown.

[0098] RT-DETRHead:

[0099] RT-DETR (Real-Time Detection Transformer) combines the advantages of the Transformer architecture and realizes an end-to-end solution for the target detection task. It is an efficient target detection model. The head part of RT-DETR is mainly composed of Encoder and Decoder. In the Encoder, the efficient hybrid encoder converts multi-scale features into image feature sequences through intra-scale feature interaction attention (AIFI) and cross-scale feature fusion module (CCFM). Using IoU-aware query selection, a fixed number of image features are selected as the initial object query of the encoder, so that the model can focus on the most relevant targets in the scene, thereby improving the detection accuracy. The decoder part is one of the cores of RT-DETR. It processes the output features of the encoder through self-attention and cross-attention. Among them, the self-attention mechanism enables each query in the decoder to take into account the information of other queries, which helps the model handle overlapping or interrelated targets. The cross-attention mechanism allows object queries to interact with the feature map of the encoder, which helps the model learn the spatial location information of the target. The head structure of RT-DETR is as follows: Figure 6 shown.

[0100] Then get the training dataset:

[0101] In one embodiment of the present invention, the image dataset of pineapple production areas acquired by drones contains 153 images and 32,371 objects, which are randomly divided into training set, validation set, and test set in a ratio of 8:1:1. Some images in the dataset are as follows: Figure 7 shown.

[0102] Then, the improved YOLOV8 structure is trained based on the training set to generate a pineapple detection model.

[0103] For the sample images in the training set, the areas where pineapples exist are manually marked to generate labels. Based on the samples and labels, the improved YOLOV8 structure is supervised trained to generate a pineapple detection model.

[0104] An embodiment of the present invention trains a model on an experimental platform equipped with an AMD Ryzen 9 7900X CPU and an NVIDIA GeForce RTX 4090 GPU, uses Pytorch 2.2.0 and torchvision 0.17.0 to build a deep learning network, uses Cuda 12.2 to accelerate GPU computing, and the experimental platform operating system is Linux 20.04. Training epochs is set to 300, the initial learning rate is set to 0.01, the weight-decay is set to 0.0005, the network uses stochastic gradient descent, and the SGD momentum is set to 0.937.

[0105] Finally, pineapple detection is performed on drone aerial photos of pineapple producing areas based on the pineapple detection model.

[0106] Specifically, obtain an aerial picture of a pineapple production area taken by a drone, input the picture into a pineapple detection model, and detect whether the aerial picture contains a pineapple. If so, provide the location information of the pineapple.

[0107] An embodiment of the present invention conducts an evaluation experiment on the method of the present invention. The evaluation indicators include precision Precision, recall rate Recall and mean average precision mAP (mean average Precision), F1-score. Among them, precision indicates how many samples detected as specified targets are real targets, reflecting the accuracy of the detection result. Recall rate indicates how many targets are correctly detected in all image samples, reflecting the integrity of the target. F1-score is an indicator used in statistics to measure the accuracy of binary classification models, which comprehensively considers precision and recall rate. The closer the score is to 1, the better the performance of the model. The AP value reflects the effectiveness of the model in identifying a certain category. The mean average precision mAP is the average of the mean precision AP values ​​of all categories, and is used as an indicator to measure the average performance of the model in all categories.

[0108] Experimental results and analysis:

[0109] Ablation experiment

[0110] The following table is for Figure 1 Results of ablation experiments using the method described in S110-S120:

[0111]

[0112] It can be seen that under the same experimental platform and the same test set conditions, the baseline model without using the improved strategy achieved an accuracy of 82.5%, a recall rate of 64%, and a mAP@0.5 of 71.2%; after replacing the detection head with RT-DETRHead, the model achieved an accuracy of 83.1%, a recall rate of 69%, and a mAP@0.5 of 73.9%, indicating that RT-DETRHead has a certain improvement on the model accuracy and can help the model improve its detection ability; after adding BiFPN and fusing the small target detection layer, the model achieved an accuracy of 85.6%, a recall rate of 69%, and a mAP@0.5 of 75%. It can be seen that the BiFPN fused with the small target detection layer has improved the network's ability to extract target features; finally, after adding the attention mechanism Coordinate Attention to the model, the model achieved an accuracy of 84.9%, a recall rate of 69%, and a mAP@0.5 of 76%. It can be seen that when using RT-DETRHead, fusing the BiFPN of the small target detection layer, and adding the attention mechanism Coordinate Attention, the model achieved an accuracy of 84.9%, a recall rate of 69%, and a mAP@0.5 of 76%. The YOLOv8 model after Attention has been greatly improved in terms of target feature extraction and target detection capabilities, with an accuracy improvement of 2.4%, a recall increase of 5%, and a mAP@0.5 increase of 4.8% compared to the baseline model. The size of the baseline model is 21.4MB. After replacing the detection head, the model size has increased, but after adding BiFPN with a small target detection layer, the model size has decreased by 24.5%. The model size after adding the attention mechanism Coordinate Attention is still 1.4MB lower than the baseline model. It can be seen that BiFPN with a small target detection layer has a good effect on optimizing the model size.

[0113] Comparative experiment:

[0114] The evaluation experiment will Figure 1 The performance of the method described in S110-S120 (reduced to PCD-YOLO) is compared with other classic target detection algorithms, including Centernet, FasterR-CNN, SSD, Retainnet, and v3, v5, X, v7, and v8 in the YOLO series. The comparison results are shown in the following table:

[0115]

[0116] It can be seen that compared with other classic target detection algorithms, the PCD-YOLO proposed in this paper achieves the highest recall rate, mAP@0.5 value and F1-score with a model volume of 20.1MB. Centernet adopts an anchor-free strategy and uses the center point of the bounding box to represent each target, but Centernet has a low recall rate and mAP value in the task of detecting pineapples in this paper; Faster R-CNN integrates feature extraction, positioning, classification and other tasks together, but the detection accuracy is low on the dataset in this paper; SSD and Retainnet are both single-stage algorithms, and their detection accuracy is not ideal for the complex pineapple field environment in the dataset in this paper; YOLOv3, YOLOv5, YOLO-X, and YOLOv7 are classic representatives in the YOLO series. Except for YOLOv7, the detection accuracy of other YOLO series algorithms on the dataset in this paper exceeds 50%, while the model size of YOLOv3 is large, which is not conducive to transplantation and deployment; YOLOv5 has the smallest size, but its F1-score and mAP values ​​are lower than those of the PCD-YOLO proposed in this paper. Based on the experimental results, it can be seen that the PCD-YOLO proposed in this paper has better detection performance and is better than other classic target detection algorithms.

[0117] An embodiment of the present invention provides a target detection system in a complex environment. Figure 8 As shown, the target detection system 800 in a complex environment includes a memory 820 and a processor 810, wherein the memory 820 is used to store a computer program; and the processor 810 is used to implement when executing the computer program. Figure 1 The method described in S110-S120.

[0118] One embodiment of the present invention provides a computer-readable storage medium, wherein a program executable by a processor is stored, and when the executable program is executed by the processor, it is used to implement Figure 1 The method described in S110-S120.

[0119] In summary, the target detection method, device, system and computer-readable storage medium provided by the embodiments of the present invention in a complex environment, aiming at the problem of dense targets and difficult feature extraction, add a small target P2 detection layer in the network to capture target information at different scales and improve the accuracy of small target detection; for the problem of feature information loss caused by continuous convolution, the weighted bidirectional feature pyramid BiFPN is used to fuse deep semantic information and shallow position information to improve the generalization ability of the model, so that the network can effectively capture multi-scale features and improve the perception ability of high-density targets; for the situation where the pineapple leaves in the background are similar in color to the pineapple leaf crown and there are pineapple leaves blocking the pineapple fruit; introduce coordinate attention (Coordinate Attention) in the YOLOv8 network Attention) is used to enhance YOLOv8's attention to the key feature information of the pineapple small target, suppress the interference of invalid background information, and enhance the feature extraction ability of small targets in the detection network; in order to improve the detection accuracy of the model for small targets in complex backgrounds, the decoder of RT-DETR is introduced into the original YOLOv8 network as the detection head. It processes the output features of the encoder through self-attention and cross-attention, obtains more spatial position information of the target, and improves the model's ability to handle overlapping or interrelated targets.

[0120] The device embodiments described above are merely illustrative, and the units described as separate components may or may not be physically separated, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0121] Those skilled in the art will appreciate that all or some of the steps in the methods disclosed above, and the functional modules / units in the systems and devices may be implemented as software, firmware, hardware, or a suitable combination thereof.

[0122] The preferred embodiments of the present application are described above with reference to the accompanying drawings, but the scope of the rights of the present application is not limited thereto. Any modification, equivalent substitution and improvement made by a person skilled in the art without departing from the scope and essence of the present application should be within the scope of the rights of the present application.

Claims

1. A target detection method in a complex environment, characterized in that: include: Acquire drone aerial images of the target area; The aerial image is input into a trained target detection model to detect areas in the aerial image where targets to be detected exist, wherein the target detection model is based on an improved YOLOV8 structure, which is used to capture multi-scale features based on coordinate attention and fuse them across levels, and to obtain the spatial position information of the target based on attention, so as to detect dense small targets.

2. The method according to claim 1, characterized in that: The backbone network of the improved YOLOV8 structure is a weighted bidirectional feature pyramid structure based on coordinate attention and including a small target P2 detection layer, with the decoder of RT-DETR as the detection head.

3. The method according to any one of claims 1 to 2, characterized in that: The training method of the target detection model includes: In the drone aerial image, manually marking the area where the target to be detected exists to generate a labeled data set; Selecting the aerial image as a sample from the data set with labels, training the improved YOLOV8 structure based on the sample and the label to generate the target detection model; Among them, the classification loss calculation formula for training the improved YOLOV8 structure is as follows: Among them, VFL(p,q) represents the classification loss, p is the predicted IoU-aware classification score; q is the target score, γ is the weight, and α1 is the weight of the positive sample; The binary cross entropy loss is used when training the improved YOLOV8 structure. The calculation formula of the binary cross entropy loss is as follows: l n =y n *logx n +(1-y n )*log(1-x n ); Among them, Loss represents the binary cross entropy loss, N is the number of groups of objects predicted by the model, n is the number of objects predicted by the model, and y n is the nth binary label 0 or 1, x n is the probability that the nth output belongs to the label; The regression loss for training the improved YOLOV8 structure includes a first regression loss and a second regression loss; The formula for the first regression loss is as follows: DFL(S i ,S i+1 )=-((y i+1 -y)log(S i )+(y-y i )log(S i+1 )); in, Among them, DFL(S i ,S i+1 ) represents the first regression loss, y is the target true label value, i is the parameter value that distinguishes the left and right distributions of the current predicted target, and y i+1 is the right distribution value of the currently predicted target box, y i is the left distribution value of the currently predicted target box, S i S is the ratio of the difference between the right distribution and the center distribution of the predicted target box to the difference between the left and right distributions. i+1 is the ratio of the difference between the center distribution and the left distribution to the difference between the left and right distributions; The calculation formula for the second regression loss is as follows: Loss CIoU =1-CIoU; Among them, Loss CIoU represents the second regression loss, IoU represents the intersection-over-union ratio between the predicted box and the true box, ρ 2 (B,B gt ) represents the Euclidean distance between the predicted box and the true box, B is the predicted target box, and B gt is the actual target box, α2 is a balance parameter and does not participate in the gradient calculation, c represents the diagonal distance of the minimum closure area that can contain both the predicted box and the real box, v represents the aspect ratio of the predicted box to the real box, and w gt ,h gt is the width and height of the real target box; w, h are the width and height of the predicted target box. When the predicted box is the same length and width as the real box, v is 0.

4. The method according to claim 2, characterized in that: The backbone network includes multiple convolution modules and c2f modules, and the c2f modules contain skip layer connections for performing feature conversion on input data.

5. The method according to any one of claims 1-2, characterized in that: The coordinate-based attention includes: The input features are globally pooled along the horizontal and vertical directions and encoded into attention maps containing long-range dependencies along the directions respectively; Multiply the two attention maps together and apply them to the mapping of the input features.

6. The method according to claim 2, characterized in that: The p3 layer of the weighted bidirectional feature pyramid is: in, is the intermediate feature of level 3 on the top-down path, is the third-layer feature extracted from the backbone, is the output feature of level 4 on the bottom-up path, is the 4th layer feature extracted from the backbone, is the output feature of the fifth level on the bottom-up path, ω1 and ω1', ω2 and ω'2, ω3' are the weights of the corresponding feature maps, and ε is a constant.

7. The method according to claim 2, characterized in that The spatial position information of the target acquired based on attention includes: RT-DETR contains an encoder-decoder structure, where the encoder converts multi-scale features into image feature sequences through intra-scale feature interaction attention and cross-scale feature fusion modules; The decoder adopts IoU-aware query selection, selecting a preset number of image features as the initial object query for the encoder to enable the model to focus on the most relevant objects in the scene.

8. The method according to claim 7, characterized in that The decoder uses IoU-aware query selection to include: The decoder enables each query to take into account information from other queries through a self-attention mechanism, and allows object queries to interact with the encoder’s feature maps through a cross-attention mechanism.

9. A target detection system in a complex environment, characterized in that: including memory and processor, The memory is used to store computer programs; The processor is configured to implement the method according to any one of claims 1 to 8 when executing the computer program.

10. A computer-readable storage medium storing a program executable by a processor, characterized in that: The executable program is used to perform the method according to any one of claims 1 to 8 when executed by a processor.

Citation Information

Patent Citations

  • Underwater image target detection method of novel DDCE-YOLOv8s model

    CN118247645A

Cited By

  • Airborne image target detection method and system based on scale autoregression

    CN119888202A

  • Dense small target detection method and device, medium and equipment

    CN119942089A

  • Lightweight AI-based distribution line unmanned aerial vehicle edge end real-time visual identification and target detection method and system

    CN121459227A