YOLOv8 unmanned aerial vehicle image target detection method based on optimization and improvement
By introducing the GAM attention mechanism, FasterBlock module and Wise-IoU loss function into the YOLOv8 network, the UAV image target detection technology is optimized, solving the problem of insufficient accuracy and speed of small target detection in complex environments, and achieving efficient and accurate detection. Target detection.
Patent Information
- Application Number
- CN202410837962.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-26
- Publication Date
- 2024-09-27
AI Technical Summary
Existing UAV image target detection technology has insufficient detection accuracy and speed for small targets in complex environments, resulting in problems of missed detection, false detection and low detection rate.
The YOLOv8 UAV image target detection method based on optimization and improvement is adopted. By adding the GAM attention mechanism, FasterBlock module and Wise-IoU loss function to the YOLOv8 network, the feature extraction and calculation efficiency of the model are optimized, and the detection accuracy of small targets is improved. and speed.
It significantly improves the accuracy and speed of UAV image target detection, reduces the memory usage and calculation amount of the model, and meets the performance requirements of UAV real-time detection.
Smart Images

Figure CN118711089A
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of unmanned aerial vehicle high-altitude image target detection, and specifically is a unmanned aerial vehicle image target detection method based on optimized and improved YOLOv8. Background Art
[0002] UAV target detection technology, which combines machine vision and flight control, has rapidly developed into a key technology for automatic identification and tracking of specific targets. Its importance is not only reflected in the military and security fields, but also increasingly prominent in many civilian areas such as agricultural monitoring, environmental protection, traffic monitoring and disaster response.
[0003] With the advancement of drone technology, its application has gradually expanded from the military field to commercial and civilian fields, and drone target detection technology has also emerged. Unlike early drones that were mainly used for reconnaissance and surveillance, modern drones need to be capable of more complex tasks, such as dynamic target tracking, autonomous navigation, and multi-target recognition. Drones are highly portable, flexible, and unrestricted by terrain, so they can easily capture high-altitude images. However, although these high-altitude images provide a wide field of view and rich information, they also bring challenges such as small target size and terrain occlusion.
[0004] At present, although the target detection algorithm has high recognition performance for medium and large targets, the detection of small targets in complex environments still faces problems such as missed detection, false detection and low detection rate. This makes drone image target detection a challenging research field, and how to improve its accuracy and speed has become a research focus.
[0005] To this end, those skilled in the art have proposed a method for drone image target detection based on an optimized and improved YOLOv8 to solve the problems raised by the background technology. The latest version of the series, YOLOv8, developed by Ultralyt i cs, has become a leading SOTA (State-of-the-Art) model. YOLOv8 has made advanced improvements in feature extraction and processing technology, significantly improving the accuracy of target detection. Compared with other algorithms, it has shown significant advantages in detection accuracy, recall rate and speed, providing an ideal balance between speed, accuracy and efficiency. Summary of the invention
[0006] The technical problem to be solved by the present invention is to overcome the shortcomings of the above-mentioned prior art and provide a drone image target detection method based on optimized and improved YOLOv8, which is lightweight, has a fast detection speed, and reduces memory usage while ensuring detection accuracy.
[0007] In order to achieve the above object, the present invention proposes a drone image target detection method based on optimized and improved YOLOv8, comprising the following steps:
[0008] S101, using a drone to fly at high altitude to photograph the ground situation, obtain a training data set and divide the data set, wherein the training data set includes a plurality of drone image samples marked with the type and location of the target to be detected, and then perform an image enhancement operation on the image to be detected to enhance the image feature information;
[0009] S102. Based on the YOLOv8n network, the GAM attention mechanism is added after the SPPF layer of the backbone network, and the FasterBlock module is added to the neck network and the backbone network. The original C2f module is replaced by the FasterBlock module, and the Wi se-IoU loss function is introduced to obtain the Faster-GAMv8 network model.
[0010] S103, using the drone training set images to train and optimize the Faster-GAMv8 network model, and obtaining the final Faster-GAMv8 network model after 300 iterations;
[0011] S104, input the image taken by the drone to be detected into the final Faster-GAMv8 network model, and use the optimized Faster-GAMv8 network model to obtain the category and location of the target to be detected in the image of the drone to be detected.
[0012] Preferably, in step S102, the GAM attention mechanism is an advanced attention modeling framework designed to improve the performance of deep neural networks in visual recognition tasks such as image classification. GAM integrates global information to achieve refined processing of feature representation and optimizes the model's encoding strategy for input data. The GAM architecture consists of a channel attention module and a spatial attention module. The channel attention module focuses on analyzing the importance of different channels, and identifies and highlights key feature channels by learning the contribution of each channel to the final task, while suppressing those less important channels. The execution process of the channel attention mechanism is specifically as follows: for different input feature maps, first, dimension conversion is performed, and the feature maps after dimension conversion are input into MLP, and then converted to the original dimension, and S The sigmoid processing output; the spatial attention module identifies the key areas in the image in two-dimensional space, so that the model can focus on processing the distinguishing parts of the image. The specific execution process of the spatial attention module is to first reduce the number of channels and then increase the number of channels. First, the number of channels is reduced by convolution with a convolution kernel of 7 to reduce the amount of calculation, and then a convolution operation with a convolution kernel of 7 is performed to increase the number of channels and keep the number of channels consistent. Finally, the spatial attention feature map is obtained through Sigmoid output; the calculation method of the channel attention module is shown in formula (1) and formula (2):
[0013]
[0014] Among them, F1 is the input feature map, M c (F1) and M s (F2) represents the matrix weights of the channel attention and spatial attention modules respectively. The weight matrix and the initial feature map are multiplied by each other. F3 represents the final output result of the GAM attention mechanism module.
[0015] Preferably, in step S102, the core of the FasterBlock module is PConv, which includes a core part and two convolutional layers, which are responsible for performing the main feature extraction task, and two auxiliary convolutional layers, which are used to refine the feature representation. In addition, the module also integrates the Normalization operation to improve the speed and stability of the network during training. The Normalization helps to alleviate the problem of gradient disappearance or explosion by adjusting and scaling the activation output, thereby accelerating the convergence speed and improving the generalization ability of the model. Finally, the ReLU activation function is used to enhance the nonlinear expression ability of the network. The FLOPs calculation method of PConv is shown in formula (3):
[0016] FLOPS = h × w × k 2 ×c p 2 (3)
[0017] Among them, h and w represent the height and width of the input feature map, k represents the convolution kernel size, and c p Represents the number of channels that require convolution operations.
[0018] Preferably, in step S102, the Wise-IoU loss function is implemented based on the center point distance between anchor boxes, and the loss function calculation method is shown in formulas (4)-(8):
[0019] L WIoU =rR WIoU L IoU (4)
[0020] r=β / (δα β-δ ) (5)
[0021]
[0022] L IoU =1-I IoU (7)
[0023]
[0024] As a preferred solution of the optimized and improved YOLOv8 UAV image target detection system described in the present invention, it includes: an image acquisition module, an image enhancement module, an optimized YOLOv8 model module, a loss function optimization module, a model training module and a target detection module;
[0025] The image acquisition module is responsible for taking ground images by high-altitude drone flight and obtaining drone image samples containing the types and locations of targets to be detected to form a training data set;
[0026] The image enhancement module is used to perform an enhancement operation on the acquired image to be detected to enhance the image feature information and improve the accuracy of subsequent target detection;
[0027] The optimized YOLOv8 model module is used to add the GAM attention mechanism to the YOLOv8 target detection algorithm, enhance the algorithm model's ability to extract correlation features between different channels, and introduce the FasterBlock module into the backbone network and neck network of YOLOv8 to replace the original C2f module, thereby reducing the computational complexity of the overall model and optimizing the parameters and computational efficiency of the model;
[0028] The loss function optimization module is used to use the Wise-IoU loss function to enable the algorithm model to more intelligently allocate gradient gains, increase the model's attention to general quality anchor frames, and reduce excessive attention to high-quality and low-quality anchor frames, thereby improving the overall accuracy of the algorithm;
[0029] The model training module uses the drone training set images to train and optimize the optimized Faster-GAMv8 network model, and obtains the final model after multiple rounds of iterations;
[0030] The target detection module is used to input the drone image to be detected into the finally trained Faster-GAMv8 network model, and use the model to quickly and accurately identify the target category and its location in the image.
[0031] A computer device includes a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of a method for recommending nutrition during pregnancy based on big data when executing the computer program.
[0032] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps of a method for recommending nutrition during pregnancy based on big data.
[0033] The present invention adds the GAM attention mechanism to the YOLOv8 target detection algorithm, strengthens the algorithm model's ability to propose correlation features between different channels, adds the FasterBlock module to the YOLOv8 backbone network and the neck network, and replaces the original C2f module with the FasterBlock module, which can greatly reduce the calculation amount of the overall model, optimize the model's parameters and calculation efficiency, and finally uses the Wi se-LoU loss function to enable the algorithm model to more intelligently allocate gradient gains, thereby increasing the model's attention to general quality anchor frames, while reducing excessive attention to high-quality and low-quality anchor frames, and improving the overall accuracy of the algorithm;
[0034] The present invention introduces a global attention mechanism GAM on the basis of the YOLOv8 algorithm framework. The integration of this mechanism significantly enhances the ability of YOLOv8 in the feature extraction process, effectively reduces the redundancy of feature information, and optimizes the model's attention allocation to key areas in the image, thereby improving the expression of features. Further, the present invention improves the C2f module in the original network structure and replaces it with the FasterBlock module. The FasterBlock module effectively reduces the floating-point operation amount of the model by means of the partial convolution PConv principle, realizes the lightweight of the network structure, and improves the operation efficiency of the model. In addition, the present invention also optimizes the loss function of the network. By introducing the Wis-LoU loss function, the present invention effectively controls the harmful gradient caused by the low-quality image anchor frame data, thereby significantly improving the positioning accuracy of the network for small targets. The experimental results on the drone image dataset show that the introduced GAM mechanism has achieved significant performance improvement in the small target detection task. At the same time, the lightweight strategy of the FasterBlock module has also been experimentally verified, proving its effectiveness in improving the operation efficiency of the model.
[0035] Compared with the prior art, the present invention has the following beneficial effects:
[0036] The method of the present invention effectively improves the accuracy and speed of target detection in images taken by unmanned aerial vehicles, reduces the memory usage of the model, reduces the calculation amount of the algorithm model, and better meets the performance requirements of real-time detection of unmanned aerial vehicles. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] Figure 1 This is a flow chart of the method for detecting target in UAV images based on optimized and improved YOLOv8 of the present invention;
[0038] Figure 2 It is an architecture diagram of the Faster-GAMv8 network model of the present invention;
[0039] Figure 3 It is a principle diagram of the Wi se-I oU loss function of the present invention;
[0040] Figure 4 This is the structural diagram of the GAM attention mechanism of the present invention;
[0041] Figure 5 This is a structural diagram of the channel attention mechanism of the present invention;
[0042] Figure 6 This is a structural diagram of the spatial attention mechanism of the present invention;
[0043] Figure 7 It is the structural diagram of the FasterBlock module of the present invention;
[0044] Figure 8 This is a comparison chart of lightweight performance indicators of the model of the present invention;
[0045] Fig. 9 This is a framework diagram of the optimized and improved YOLOv8 drone image target detection system of the present invention. DETAILED DESCRIPTION
[0046] The following embodiments of the present invention are described in further detail in conjunction with the accompanying drawings and examples. The following examples are used to illustrate the present invention, but are not intended to limit the scope of the present invention.
[0047] Embodiment 1: The present invention provides a method for detecting targets in drone images based on an optimized and improved YOLOv8. The method is performed by a computer and includes the following steps:
[0048] S101, using a drone to fly at high altitude to photograph ground conditions to obtain a training data set, where the training data set includes a plurality of drone-photographed image samples annotated with types and locations of targets to be detected;
[0049] S102. Based on the YOLOv8n network, the GAM attention mechanism is added after the SPPF layer of the backbone network, and the FasterBlock module is added to the neck network and the backbone network. The original C2f module is replaced by the FasterBlock module, and the Wi se-I oU loss function is introduced to obtain the Faster-GAMv8 network model.
[0050] S103, using the drone training set images to train and optimize the Faster-GAMv8 network model, and obtaining the final Faster-GAMv8 network model after 300 iterations;
[0051] S104, input the image taken by the drone to be detected into the final Faster-GAMv8 network model, and use the optimized Faster-GAMv8 network model to obtain the category and location of the target to be detected in the image of the drone to be detected.
[0052] The experimental environment of this method is: operating system: Windows 11; memory: 16GB; CPU: AMD R7-7735H; GPU: NVID IA GeForceRTX 4060; video memory is 8GB; CUDA version is 11.3; development environment: Pycharm;
[0053] Furthermore, in this method, the drone shooting dataset includes multiple image samples with the locations and types of the targets to be detected. In the process of building the network model, the quality of the dataset is crucial to improving the performance of the model. An efficient dataset should have the following characteristics: First, it must have a sufficient sample size to ensure that the model can learn a wide range of features and patterns. Second, the scenes in the dataset should be diverse to cover a variety of possible application scenarios, thereby improving the generalization ability of the model. In addition, the annotations in the dataset must be accurate, including the specific locations and types of the targets to be detected, which is crucial for training the model to identify and classify different targets. In order to achieve these requirements, the construction of the dataset needs to follow strict standards and processes. The collection of samples should cover different environmental conditions and backgrounds to ensure that the model can adapt to various practical application scenarios. At the same time, the annotation process should be carried out by professionals to ensure the accuracy and consistency of the annotations. Through these measures, a high-quality data set can be constructed, thus providing a solid foundation for the training of the network model and ensuring that the model can achieve a high recognition accuracy in practical applications; the data set has a total of 7019 images, including 12 types of ground targets to be detected, and is divided into training sets, validation sets, and test sets in a ratio of 6:2:2. Each image sample will contain one or more types of targets to be detected, and will also contain multiple numbers of the same type of targets to be detected.
[0054] Furthermore, the YOLO (You Only Look Once) algorithm, as a pioneering work in the field of object detection, proposes an end-to-end neural network architecture to transform the object detection problem into a unified regression problem. The algorithm simplifies the traditional multi-stage detection process by directly predicting the category and bounding box position of the target, thereby significantly improving the detection speed and making it perform well in real-time object detection tasks. However, the YOLO algorithm has limitations when dealing with dense target scenes, especially when multiple targets overlap in a single cell, its detection performance will be significantly affected. This is because each cell of the YOLO algorithm can only predict a limited number of bounding boxes, usually two, which limits its adaptability to complex scenes. To overcome this challenge, subsequent versions of the YOLO algorithm have made a number of improvements. YOLOv2 introduced anchor boxes and batch normalization techniques to improve the generalization ability and detection accuracy of the model. YOLOv3 further optimized the network structure, adopted multi-scale prediction and a new loss function, and enhanced the detection ability of targets of different sizes. YOLOv4 introduced CSPDarknet53 as the backbone network, and further improved the model's feature extraction and multi-scale prediction capabilities through the SPP-X module and PANet structure. YOLOv5, based on YOLOv4, improved the ease of use and performance of the model through improved data processing and training strategies. Subsequent versions such as YOLOv6, YOLOv7, and YOLOv8 continue to innovate in network structure, loss function, training techniques, etc. to cope with the growing complexity and real-time requirements. These improvements not only improve the performance of the YOLO algorithm in dense target detection, but also expand its applicability in different application scenarios.
[0055] In summary, the present invention innovatively integrates the global attention mechanism GAM on the basis of the YOLOv8 algorithm framework. The introduction of this mechanism significantly improves the performance of YOLOv8 in the feature extraction stage, optimizes the attention allocation to key areas in the image by reducing the redundancy of feature information, and thus enhances the feature expression ability of the model. Furthermore, the present invention makes a key improvement to the C2f module in the YOLOv8 network structure, and replaces the original module with the FasterBlock module. The FasterBlock module uses the principle of partial convolution to effectively reduce the floating-point operation requirements of the model, realizes the lightweight of the network structure, and thus improves the computational efficiency of the model. In addition, the present invention finely optimizes the loss function of the network and introduces the Wise-IoU loss function. This innovation effectively controls the harmful gradients caused by low-quality image anchor frame data, significantly improves the positioning accuracy of the network for small targets, especially in the application of drone image data sets. These improvements provide an efficient and accurate solution for drones to perform image target detection in complex environments, which has important practical application value and promotion potential.
[0056] The present embodiment will be further described below in conjunction with the accompanying drawings:
[0057] like Figure 2 As shown in the figure, the present invention proposes a Faster-GAMv8 network model architecture diagram based on an optimized and improved YOLOv8 drone image target detection system. The model structure is mainly divided into three modules, namely the backbone network (Backbone), the neck (Neck), and the head (Head). The network model in the figure uses GAM (Global Attention Mechanism) in the Backbone part, which improves the ability to extract global features, improves the receptive field of the model, and enhances the feature expression ability. The C2f module in the original network Neck is replaced by the FasterBlock module. The FasterBlock module adopts the partial convolution principle, reduces the floating-point operation amount of the model, and makes the improved network more lightweight than the original network. According to the experimental results on the VOCdevkit data set, the GAM attention mechanism has significantly improved the effect of small target detection, and the lightweight characteristics of the FasterBlock method have also been verified.
[0058] like Figure 3As shown in the figure, the present invention adopts the Wise-IoU loss function instead of CI oU and adopts a dynamic non-monotonic attention mechanism, and enhances the performance of the target detection model by introducing an additional penalty mechanism and an improved calculation method. (x, y) and (xgt, ygt) are the coordinates of the center points of the predicted box and the true box, respectively. In the figure, a line connects the center point (x, y) of the predicted box and the center point (xgt, ygt) of the true box, representing the Euclidean distance between the two. The distance between the center points of the predicted box and the true box is an important indicator in the calculation of the loss function of target detection. It helps to measure the proximity of the predicted box and the true box in spatial position. The pink area reflects the overlap of the two boxes. Wise-IoU can more accurately reflect the geometric difference between the predicted box and the true box, thereby improving the positioning accuracy, providing a larger gradient for the bounding box with less overlap, prompting the model to converge faster during training, and having stronger robustness for various complex scenes.
[0059] like Figure 4 As shown, the present invention adopts GAM attention mechanism, and this framework is composed of channel attention module (Channel Attention) and spatial attention module (Spatial Attention), which is an advanced attention modeling framework for enhancing feature representation capability. The left side of the figure is input feature, which is expressed as F1. The input feature first passes through the channel attention module, and the channel attention module is used to calculate the importance weight of each channel, and outputs a channel weight matrix Mc, and the input feature F1 and the channel weight matrix Mc are element-multiplied. This step can weight the input feature in the channel dimension, generate weighted features, and the features after channel weighting pass through the spatial attention module again, and the spatial attention module is used to calculate the importance weight of each spatial position, and outputs a spatial weight matrix Ms, and the features after channel attention processing are element-multiplied with the spatial weight matrix Ms, and output feature F3, and the features are processed by weighted processing of channel and spatial attention, and have stronger feature representation capability. Through the weighted operation of attention in two steps, the representation capability of feature map is significantly improved, so that it can better capture important information, and the encoding strategy of model to input data is optimized.
[0060] like Figure 5As shown in the figure, the channel attention module retains information in three dimensions: channel, height, and width by utilizing 3D permutation. The module uses a two-layer multi-layer perceptron (MLP) to enhance the dependencies across channels and spatial dimensions. As an encoding-decoding structure, MLP can learn the nonlinear relationship between channels and improve the model's ability to perceive the importance of channels. Specifically, for the input feature map, the dimension is first transformed, and the transformed feature map is input into the MLP for processing, and then converted back to the original dimension and processed by the Sigmoid function, and finally the weighted feature map is output. The feature representation ability is improved, so that the model can better capture important information.
[0061] like Figure 6 As shown in the figure, in the spatial attention module, a convolution operation with a convolution kernel of 7 is first used to reduce the number of channels, thereby reducing the amount of calculation. Then, another convolution operation with a convolution kernel of 7 is used to increase the number of channels to maintain consistency with the number of channels in the original feature map. Finally, the output is generated through the Sigmoid activation function. The spatial attention module adaptively weights the input feature map through efficient calculation and enhanced feature representation capabilities, thereby improving the model's ability to focus on important spatial information. While maintaining channel consistency, the detection accuracy of the model is significantly improved, making it suitable for various computer vision tasks.
[0062] like Figure 7 As shown in the figure, the core of the FasterBlock module is partial convolution (PConv). In addition, the module also contains a core part, two convolution layers, a normalization operation (Normalization) to improve training speed and stability, and a ReLU activation layer to enhance the network's expressiveness. PConv has a lower number of floating-point operations (FLOPs) than conventional convolution (Conv), and shows a higher FLOPs utilization than depthwise separable convolution (DWConv) and grouped convolution (GConv), which can better utilize the computing resources of the device. PConv only performs feature extraction operations on a small part of the channels of the input feature map, and does not perform relevant operations on the remaining channels (from cp channels to c channels). It is generally believed that the output feature map and the input feature map have the same number of channels.
[0063] like Figure 8 As shown, Figure 8The comparison of various target detection models in terms of parameter volume, floating point computation (FLOPs), and number of convolutional layers is shown. The floating point computation volume of Faster-GAMv8 is 7.6, which is significantly lower than other models. Low FLOPs means that the model has lower computational requirements and is more suitable for deployment in resource-constrained environments. The number of parameters of Faster-GAMv8 is 3,945,718, which is slightly higher than YOLOv8n (3,011,222), but much lower than YOLOv5s (9,153,152) and YOLOv7 (37,200,095). Fewer parameters means that the model is lighter, faster in training and inference, and requires less memory. Faster-GAMv8 has 256 convolutional layers, which is less than YOLOv7 (407) and YOLOv5s (262). This means that the structure of the model is relatively simple, and the computational complexity during training and inference is lower. Although the number of convolutional layers is relatively small, Faster-GAMv8 can still provide enough network depth to capture complex features. This makes the model have better stability and generalization ability during training. The Faster-GAMv8 model has significant advantages in computational efficiency, model lightweight and performance stability through effective structural design.
[0064] Embodiment 2: Fig. 9 As shown, the present invention proposes a preferred solution of an unmanned aerial vehicle image target detection system based on an optimized and improved YOLOv8, which includes: an image acquisition module, an image enhancement module, an optimized YOLOv8 model module, a loss function optimization module, a model training module and a target detection module;
[0065] Furthermore, the image acquisition module is responsible for taking ground images by high-altitude drone flight, and obtaining drone image samples containing the types and locations of targets to be detected to form a training data set; the image enhancement module is used to enhance the acquired images to be detected to enhance the image feature information and improve the accuracy of subsequent target detection; the YOLOv8 model optimization module is used to add the GAM attention mechanism to the YOLOv8 target detection algorithm, enhance the algorithm model's ability to extract correlation features between different channels, and introduce the FasterB l ock module in the backbone network and neck network of YOLOv8 to replace the original C2f module, reduce the calculation amount of the overall model, and optimize the parameters and calculation efficiency of the model; the loss function optimization module is used to use Wi The se-IoU loss function enables the algorithm model to allocate gradient gains more intelligently, improve the model's attention to general quality anchor frames, and reduce excessive attention to high-quality and low-quality anchor frames, thereby improving the overall accuracy of the algorithm; the model training module uses the drone training set images to train and optimize the optimized Faster-GAMv8 network model, and obtains the final model after multiple rounds of iterations; the target detection module is used to input the drone-taken images to be detected into the finally trained Faster-GAMv8 network model, and use the model to quickly and accurately identify the target category and its location in the image.
[0066] Furthermore, if the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in various embodiments of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0067] exist Fig. 9The logic and / or steps represented in or otherwise described herein, for example, may be considered as an ordered list of executable instructions for implementing logical functions, and may be embodied in any computer-readable medium for use by an instruction execution system, apparatus, or device (such as a computer-based system, a system including a processor, or other system that can fetch instructions from an instruction execution system, apparatus, or device and execute instructions), or in conjunction with such instruction execution systems, apparatuses, or devices. For purposes of this specification, "computer-readable medium" may be any device that can contain, store, communicate, propagate, or transmit a program for use by an instruction execution system, apparatus, or device, or in conjunction with such instruction execution systems, apparatuses, or devices.
[0068] More specific examples of computer-readable media (a non-exhaustive list) include the following: an electrical connection with one or more wires (electronic device), a portable computer disk case (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable and programmable read-only memory (EPROM or flash memory), an optical fiber device, and a portable compact disk read-only memory (CDROM). In addition, the computer-readable medium may even be a paper or other suitable medium on which the program is printed, since the program may be obtained electronically, for example, by optically scanning the paper or other medium, followed by editing, deciphering or, if necessary, processing in another suitable manner, and then stored in a computer memory.
[0069] Additionally, in order to provide a concise description of exemplary embodiments, all features of an actual embodiment (ie, those features that are not relevant to the best mode presently contemplated for carrying out the invention or those that are not relevant to implementing the invention) may not be described.
[0070] It will be appreciated that in the development of any actual implementation, as in any engineering or design project, numerous implementation-specific decisions may be made. Such a development effort may be complex and time-consuming, but will be a routine task of design, fabrication, and production for those of ordinary skill having the benefit of this disclosure without undue experimentation.
[0071] The embodiments of the present invention are provided for the purpose of illustration and description. Although the embodiments of the present invention have been shown and described above, it can be understood that the above embodiments are exemplary and cannot be understood as limitations of the present invention. Ordinary technicians in this field can change, modify, replace and modify the above embodiments within the scope of the present invention.
Claims
1. A method for detecting targets in drone images based on optimized and improved YOLOv8, characterized in that: The following steps are involved: S101, using a drone to fly at high altitude to photograph ground conditions, obtain a training data set and divide the data set, wherein the training data set includes a plurality of drone-photographed image samples annotated with types and locations of targets to be detected; S102. Then, based on the YOLOv8n network, the GAM attention mechanism is added after the SPPF layer of the backbone network, and the FasterBlock module is added to the neck network and the backbone network. The original C2f module is replaced by the FasterBlock module, and the Wise-IoU loss function is introduced to obtain the Faster-GAMv8 network model. S103, using the drone training set images to train and optimize the Faster-GAMv8 network model, and obtaining the final Faster-GAMv8 network model after 300 iterations; S104, input the image taken by the drone to be detected into the final Faster-GAMv8 network model, and use the optimized Faster-GAMv8 network model to obtain the category and location of the target to be detected in the image of the drone to be detected.
2. A method for detecting targets in unmanned aerial vehicle images based on an optimized and improved YOLOv8 as claimed in claim 1, characterized in that: In step S102, the GAM attention mechanism is an advanced attention modeling framework designed to improve the performance of deep neural networks in visual recognition tasks such as image classification. GAM integrates global information to achieve refined processing of feature representation and optimizes the model's encoding strategy for input data. The GAM architecture consists of a channel attention module and a spatial attention module. The channel attention module focuses on analyzing the importance of different channels, and by learning the contribution of each channel to the final task, it identifies and highlights key feature channels while suppressing less important channels. The specific execution process of the channel attention mechanism is to first perform dimensional conversion for different input feature maps. , the feature map after dimension conversion is input into MLP, and then converted into the original dimension, and Sigmoid processing is performed for output; the spatial attention module identifies the key areas in the image in two-dimensional space, so that the model can focus on processing the distinguishing parts of the image. The execution process of the spatial attention module is to reduce the number of channels first, and then increase the number of channels. First, the number of channels is reduced by convolution with a convolution kernel of 7 to reduce the amount of calculation, and then a convolution operation with a convolution kernel of 7 is performed to increase the number of channels and keep the number of channels consistent. Finally, the spatial attention feature map is obtained through Sigmoid output; the calculation method of the attention module is shown in formula (1) and formula (2): Among them, F1 is the input feature map, M c (F1) and M s (F2) represents the matrix weights of the channel attention and spatial attention modules respectively. The weight matrix and the initial feature map are multiplied by each other. F3 represents the final output result of the GAM attention mechanism module.
3. A method for detecting targets in unmanned aerial vehicle images based on an optimized and improved YOLOv8 as claimed in claim 1, characterized in that: In step S102, the core of the FasterBlock module is PConv, which includes a core part and two convolutional layers, which are responsible for performing the main feature extraction task, and two auxiliary convolutional layers, which are used to refine the feature representation. In addition, the module also integrates the Normalization operation to improve the speed and stability of the network during training. The Normalization helps to alleviate the problem of gradient disappearance or explosion by adjusting and scaling the activation output, thereby accelerating the convergence speed and improving the generalization ability of the model. Finally, the ReLU activation function is used to enhance the nonlinear expression ability of the network. The FLOPs calculation method of PConv is shown in formula (3): FLOPS=h×w×k 2 ×c p 2 (3) Among them, h and w represent the height and width of the input feature map, k represents the convolution kernel size, and c p Represents the number of channels that require convolution operations.
4. A method for detecting targets in unmanned aerial vehicle images based on an optimized and improved YOLOv8 as claimed in claim 1, characterized in that: In step S102, the Wise-IoU loss function is implemented based on the center point distance between anchor boxes, and the loss function calculation method is shown in formulas (4)-(8): L WIoU =rR WIoU L IoU (4) r=β / (δα β-δ ) (5) L IoU =1-I IoU (7) 5. A drone image target detection system based on optimized and improved YOLOv8 as claimed in any one of claims 1 to 4, characterized in that: It includes image acquisition module, image enhancement module, YOLOv8 model optimization module, loss function optimization module, model training module and target detection module; The image acquisition module is responsible for taking ground images by flying a drone at high altitude, and obtaining drone image samples containing the types and locations of the targets to be detected to form a training data set; The image enhancement module is used to perform an enhancement operation on the acquired image to be detected to enhance the image feature information and improve the accuracy of subsequent target detection; The optimized YOLOv8 model module is used to add the GAM attention mechanism to the YOLOv8 target detection algorithm, enhance the algorithm model's ability to extract correlation features between different channels, and introduce the FasterBlock module into the backbone network and neck network of YOLOv8 to replace the original C2f module, thereby reducing the computational complexity of the overall model and optimizing the model's parameters and computational efficiency; The loss function optimization module is used to use the Wise-IoU loss function so that the algorithm model can more intelligently allocate gradient gains, increase the model's attention to general quality anchor frames, and reduce excessive attention to high-quality and low-quality anchor frames, thereby improving the overall accuracy of the algorithm; The model training module uses the drone training set images to train and optimize the optimized Faster-GAMv8 network model, and obtains the final model after multiple rounds of iterations; The target detection module is used to input the drone image to be detected into the finally trained Faster-GAMv8 network model, and use the model to quickly and accurately identify the target category and its location in the image.
6. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 4 are implemented.
7. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 4 are implemented.
Citation Information
Cited By
Multi-target tracking method, system and equipment based on attention mechanism enhancement
CN118898637A
Visual positioning method for contact network cantilever mounting manipulator
CN119347798A
Lightweight service robot target detection method and device
CN119399438A
Brain MRI image tumor detection method based on improved YOLOv7
CN119963535A
Crop main body identification and positioning method based on machine vision and application
CN121191157A
