Small target detection method and system based on improved YOLOv8
By adding the EMA module to the YOLOv8 model, replacing the C2f module with the C2f_DSConv module, and using the Inner-ShapeIoU loss function, the problems of occlusion, background interference, multi-scale and insignificant features in small object detection are solved, and the high-precision and stable small object detection effect is achieved.
Patent Information
- Application Number
- CN202510078895.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-17
- Publication Date
- 2025-04-25
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
The existing object detection algorithms have problems such as occlusion, background interference, multi-scale and visual features in small object detection, resulting in low detection accuracy and positioning accuracy.
The EMA module is added after the SPPF module of the YOLOv8 model, replace the C2f module with the C2f_DSConv module, and replace the CIoU loss function with Inner-ShapeIoU to enhance small-objective feature capture, adapt to complex local features and improve bounding box regression accuracy.
It significantly improves the accuracy and stability of small object detection, enhances the model's adaptability and generalization ability to complex scenarios, and reduces missed and missed detection.
Smart Images

Figure CN119888365A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of target detection, and in particular relates to a small target detection method and system based on improved YOLOv8. Background Art
[0002] Computer vision is known as the "eyes" of artificial intelligence and is an important branch of the field of artificial intelligence. It simulates the functions of the human eye through cameras and computers to achieve automatic analysis and processing of images or videos, helping machines to better understand and interpret visual information. Object detection is one of its core tasks, which is to identify and locate objects of different categories in images. Object detection is widely used in fields such as autonomous driving, security monitoring, and medical diagnosis, and has had an important impact on these industries. At the same time, object detection is also the basis of higher-level visual tasks such as target tracking and target segmentation, and its core lies in target classification and positioning. However, traditional object detection algorithms tend to construct features manually, which usually have problems such as low speed and limited accuracy, and are the mainstream solutions in early applications.
[0003] With the development of convolutional neural networks, deep learning-based target detection algorithms have gradually taken a leading position in research due to their simple structure and excellent performance. Compared with traditional methods, these algorithms have greatly improved the accuracy and speed of detection. At present, such algorithms are mainly divided into single-stage models and two-stage models. The single-stage model uses a regression method, directly inputs the image to generate the detection result, and then directly outputs it, using an end-to-end approach; the two-stage model first generates candidate regions through a convolutional neural network, and then further completes classification and positioning. Classic representative algorithms include the R-CNN series, YOLO, SSD, etc. They have become powerful technical tools in actual scenarios and provide solid support for applications in multiple fields.
[0004] Compared with other computer vision tasks, the research history of small target detection is relatively short. In 2014, the MSCOCO dataset defined targets with a resolution less than 32×32 pixels as small targets. In 2016, researchers proposed a small target detection network based on deep learning, and defined targets of the same category that occupy 0.05%-0.58% of the total area as small targets by introducing a special small target detection dataset and its evaluation indicators from the perspective of relative size of the target, which provided a foundation for the research of small target detection.
[0005] Small target detection is a special and challenging field in target detection. Since small targets occupy fewer pixels in the image, it is difficult to fully extract the target features. At the same time, the feature expression ability is weak, and small targets are prone to lose information when the image is downsampled, which makes it difficult to fully represent their features in the deep network. In addition, the distribution of small targets is uneven, which may be sparsely distributed (such as a single target in remote sensing images) or densely distributed (such as crowded people). Small targets are very common in many application scenarios, such as vehicles and pedestrians in remote sensing images, lesions in medical images, or pedestrians and animals from the perspective of drones. Although these targets are small in size, they are usually of great significance in practical applications. However, due to the characteristics of small targets themselves and the limitations of existing target detection algorithms, detecting small targets still faces great challenges. Although domestic and foreign scholars have made certain progress in this field, there are still some unresolved issues in small target detection.
[0006] Through the above analysis, the problems and defects of the prior art are as follows:
[0007] (1) Occlusion problem: Occlusion overlap between targets will significantly affect the performance of the detection algorithm. The existing detection algorithm has a low recognition rate when small targets are occluded, especially in dense scenes. The occlusion problem is more serious, resulting in reduced accuracy of small target detection results, requiring more powerful context information understanding capabilities;
[0008] (2) Background interference: Small targets are often easily confused with complex backgrounds and are easily affected by the background. Especially when the background and target are similar in color, the textures overlap, or the ambient light is complex, the detection algorithm is easily affected by noise and it is difficult to extract sufficient feature information, thereby reducing the recognition effect and positioning accuracy of small targets.
[0009] (3) Multi-scale problem: In the target detection task, large targets and small targets coexist. The detection requirements of targets of different sizes make it difficult to balance network performance.
[0010] (4) The visualization features are not obvious: Due to limited pixel information, the visualization features of small objects are usually not obvious. Summary of the invention
[0011] In view of the problems existing in the prior art, the present invention provides a small target detection method based on improved YOLOv8.
[0012] The present invention is implemented in this way: a small target detection method based on improved YOLOv8 includes:
[0013] Step 1: Add a new EMA module after the SPPF module of the original YOLOv8 model: instead of the traditional downsampling method, it can fully obtain all pixel-level information in each channel dimension and enhance the capture of small target information;
[0014] Step 2: Introduce DSConv convolution into C2f convolution in the original YOLOv8 model, and partially replace the original C2f module with C2f_DSConv module;
[0015] Step 3: Replace the CIoU loss function used in the original YOLOv8 model with Inner-ShapeIoU.
[0016] Furthermore, the EMA module:
[0017] Assume any original input tensor X∈R C×H×W , where C represents the number of input channels, H and W represent the spatial dimensions of the input features respectively; in order to capture the relationship between channels, EMA adopts a parallel substructure consisting of two 1×1 branches and one 3×3 branch to extract the attention weight descriptor of the grouped feature map; in order to learn different semantics, EMA divides X into G sub-features in the channel dimension direction, with X=[X0,X i ,…X G-1 ],R C / / G×H×W In the form of, without loss of generality, let G<<C, and assume that the learned attention weight descriptor will be used to enhance the feature representation of the region of interest in each sub-feature; the 1×1 branch realizes cross-channel interaction features, and two one-dimensional global average pooling is used to encode the channels in two spatial directions. The one-dimensional global average pooling output in the horizontal dimension and the vertical dimension is shown in equations (1) and (2);
[0018]
[0019] Among them, x c is the input feature of the cth channel, i and j represent the position of the feature in the horizontal direction W and the vertical direction H respectively. as well as is the global average pooling output;
[0020] The 3×3 branch captures local cross-channel interactions through 3×3 convolution to expand the feature space; in EMA, two-dimensional global average pooling is used to encode the global spatial information of the output of the 1×1 branch, and the output of the smallest branch is directly converted into the corresponding dimensional shape before the channel feature joint activation mechanism, that is, Use two-dimensional global average pooling for different branches, see formula (3);
[0021]
[0022] Among them, x c is the input feature of the cth channel, (i, j) represents the location of the feature, Z c Represents the 2D global average pooling output.
[0023] Further, the C2f_DSConv module:
[0024] Given a standard 2D convolution coordinate K, the center coordinate is K i =(x i ,y i ); then a 3×3 convolution kernel K is shown in formula (4);
[0025] K={(x-1,y-1),(x-1,y),…,(x+1,y+1)} (4)
[0026] In dynamic snake convolution, the standard convolution is linearized in the x-axis and y-axis directions; a 9×9 convolution kernel is used. Taking the x-axis direction as an example, each specific position of the convolution kernel can be expressed as K i±c =(x i±c ,y i±c ), where c = {0, 1, 2, 3, 4} represents the horizontal distance from the center grid of the convolution kernel, K i±c It is a cumulative process, starting from the center position K i Initially, the position of the grid away from the center depends on the position of the previous grid: K i+1 Relative to K i An offset Δ={δ|δ∈[-1,1]} is added; in the process of changing along the x-axis, the offset Δ will be continuously accumulated, so as to ensure that the receptive field of the convolution kernel forms a continuous linear morphological structure; the process of changing along the y-axis is similar to that along the x-axis, that is, the x-shaped convolution on the right is formed; the maximum value of the horizontal offset c of the center grid is 4, then the standard convolution kernel can be obtained after multiple iterations. The expressions in the x-axis direction and the y-axis direction are shown in equations (5) and (6);
[0027]
[0028] Since the offset Δ is usually a decimal, and the coordinates are integers, the bilinear interpolation method is used, as shown in formula (7);
[0029] K=Σ K' B(K',K)·K' (7)
[0030] Where K is the position of the decimal format in equations (5) and (6), K' lists all the positions of the integer format, and B is the bilinear interpolation kernel, which can be decomposed into two one-dimensional kernels, as shown in equation (8);
[0031] B(K,K')=b(K x ,K' x )·b(K y ,K' y ) (8)
[0032] Among them, K x 'And K' y Respectively represent the integer positions in the x-axis direction and the y-axis direction, K x With K y Respectively represent the position of the target decimal format in the x-axis direction and the y-axis direction.
[0033] Furthermore, the Inner-ShapeIoU:
[0034] The bounding box regression loss function is an important part of object detection. The accuracy of object detection depends on it to a large extent. The loss function used by YOLOv8 is CIoU, which is calculated as shown in equations (9), (10), and (11);
[0035]
[0036] Among them, ρ 2 *(B,B gt ) is used to represent the center point B of the predicted box and the center point B of the real box gt The Euclidean distance between them, c is the diagonal length of the minimum circumscribed rectangle covering the two boxes, ν is used to measure the similarity of aspect ratios, and α is used as a weight coefficient;
[0037] Inner-IoU introduces a scaling factor ratio to control the size of the auxiliary box for calculating the loss. The definition of Inner-IoU is shown in equations (12)-(18);
[0038]
[0039]
[0040] union=(w gt *h gt )*(ratio) 2 +(w*h)*(ratio) 2 -inter, (17)
[0041]
[0042] Among them, the center points of the real box and the inner-real box are Indicates that the center point of the prediction box and the inner-prediction box is (x c ,y c) indicates that the width and height of the real box are represented by w gt and h gt , the width and height of the prediction box are represented as w and h respectively, inter is the area of the middle red area, union is the union area of the auxiliary borders, and ratio, that is, the proportional factor, is generally [0.5, 1.5];
[0043] Adding Shape-IoU enables the model to focus on the shape and scale of the bounding box itself to calculate the loss function, making the bounding box regression more accurate. Its definition is shown in equations (19)-(23);
[0044]
[0045] Ω shape =Σ t=w,h (1-e -ωt ) θ ,θ=4 (22)
[0046]
[0047] Among them, scale is the scaling factor and is related to the scale of the target in the dataset, ww and hh represent the weight coefficients in the horizontal and vertical directions respectively, and their values are related to the shape of the true box, and c is the distance between the center point of the true box and the center point of the predicted box. The improved Inner-ShapeIoU is shown in formula (24);
[0048] L Shape-IoU inner =1-IoU inner +distance shape +0.5*Ω shape
[0049] (twenty four).
[0050] Another object of the present invention is to provide a small target detection system based on improved YOLOv8, comprising:
[0051] A module is added to add a new EMA module after the SPPF module of the original YOLOv8 model: instead of the traditional downsampling method, it completely obtains all pixel-level information in each channel dimension and enhances the capture of small target information;
[0052] The import module is used to introduce DSConv convolution into C2f convolution in the original YOLOv8 model, and partially replace the original C2f module with the C2f_DSConv module;
[0053] The replacement module is used to replace the CIoU loss function used in the original YOLOv8 model with Inner-ShapeIoU.
[0054] Another object of the present invention is to provide a computer device, comprising a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor executes the steps of the small target detection method based on the improved YOLOv8.
[0055] Another object of the present invention is to provide a computer-readable storage medium storing a computer program, which, when executed by a processor, enables the processor to perform the steps of the small target detection method based on the improved YOLOv8.
[0056] Another object of the present invention is to provide an information data processing terminal, which is used to implement the small target detection system based on improved YOLOv8.
[0057] In combination with the above technical solutions and the technical problems solved, the advantages and positive effects of the technical solutions to be protected by the present invention are as follows:
[0058] First, inspired by YOLOv8, the present invention proposes an improved target detection algorithm based on YOLOv8 to solve the problems of missed detection and false detection of objects in small target scenes due to occlusion, complex background and other reasons. An EMA attention mechanism module is added after SPPF to replace the traditional downsampling method, and all pixel-level information in each channel dimension is fully obtained; the original C2f module is transformed, and DSConv convolution is added to design it into a C2f_DSConv module, replacing most of the C2f in the original Backbone and Neck, so that small target features can be better captured during feature extraction; the original CIoU loss function is replaced by Inner-ShapeIoU, and shape-related loss terms and internal intersection-union ratios are introduced to enhance the ability to detect small targets. Compared with the traditional YOLOv8 algorithm in small target detection, the present invention has the following advantages:
[0059] (1) The present invention improves the detection accuracy of small targets: By introducing the EMA attention mechanism, the network can dynamically adjust the weights of feature maps, effectively focusing on the key features of small targets and occluded targets, significantly improving the detection accuracy of small targets.
[0060] (2) The present invention enhances the adaptability of the model to complex targets: combined with dynamic snake convolution (DSConv), the model can better cope with the geometric changes and complex local features of the target, and improves the recognition ability of small targets with diverse morphological changes.
[0061] (3) The present invention accelerates convergence and improves generalization ability: By replacing the loss function with Inner-ShapeIoU, the model not only significantly improves the small target positioning accuracy, but also accelerates the convergence process and enhances the generalization ability in different data sets and environments.
[0062] Second, as auxiliary evidence of the inventiveness of the claims of the present invention, it is also reflected in the following important aspects:
[0063] (1) The expected benefits and commercial value of the technical solution of the present invention after transformation are:
[0064] The present invention proposes a small target detection method based on improved YOLOv8, which further improves the accuracy and stability of small target detection, so that the present invention has better adaptability and generalization ability, can be widely used in various practical scenarios, and provides efficient and accurate technical solutions for small target detection problems in related fields, with significant economic benefits and commercial value. In the field of intelligent security, the present invention can effectively improve the detection accuracy of small targets for long-distance face recognition, abnormal behavior monitoring, border intrusion detection and other scenarios, reduce false alarms and missed alarms, improve the reliability of security systems, and reduce the cost of manual inspections; in the field of smart transportation, the present invention can be used for tasks such as vehicle identification and pedestrian detection in road monitoring, especially in long-distance or congested scenarios, the detection effect of small vehicles, non-motor vehicles and pedestrians is more accurate, thereby improving the efficiency of traffic management systems, reducing the accident rate, and ensuring road safety; in industrial quality inspection, the present invention can be used to detect small defects, such as fine cracks and flaws on the surface of products; in drone inspection scenarios, small targets (such as minor damage to overhead lines, cracks in photovoltaic panels, etc.) can be accurately identified, greatly improving inspection efficiency and reducing the risks and costs of manual inspections; in the field of autonomous driving, the algorithm of the present invention can detect small obstacles in the distance earlier and improve the safety of vehicles; in medical image analysis, the algorithm of the present invention can accurately identify small lesions and early lesion areas, improve the accuracy of disease diagnosis, and help the development of the medical industry. Based on the above application scenarios, the present invention has significant commercial prospects, can help enterprises improve product competitiveness, create commercial profits, reduce operating costs, improve work efficiency, and create long-term stable economic benefits. At the same time, due to the lightweight design and real-time advantages of the algorithm, the method is also feasible for deployment in edge computing devices, and is expected to be widely used in the future Internet of Things and edge AI markets, promote the implementation of technologies in emerging fields, and further expand market space.
[0065] (2) The technical solution of the present invention solves a technical problem that people have been eager to solve but have never been able to solve successfully:
[0066] The technical solution of the present invention successfully alleviates the technical difficulties of small target detection that have long plagued the field of computer vision, that is, to achieve high-precision detection and classification of small targets in challenging scenes such as occlusion and complex background. Traditional algorithms face the problems of insufficient feature extraction ability, difficulty in separating targets from backgrounds, and poor robustness in occlusion in small target detection, resulting in high missed detection and false detection rates, which are difficult to meet the needs of practical applications. Especially in the case of complex backgrounds or overlapping multiple targets, how to effectively distinguish targets from interference objects and accurately detect small targets has always been a technical difficulty that the industry is eager to solve but has not been able to overcome. These problems not only limit the performance of small target detection in practical applications, but also lead to its insufficient reliability and stability in complex scenes, making it difficult to meet application scenarios with high precision requirements such as unmanned driving, video surveillance, and medical image analysis. In response to these problems, the solution of the present invention effectively alleviates the problems of insufficient expression of small target features and poor adaptability of models to complex scenes through a series of innovative designs, and realizes accurate positioning and recognition of small targets in different environments, providing reliable technical support for solving the problems of robustness and accuracy of small target detection in complex scenes. BRIEF DESCRIPTION OF THE DRAWINGS
[0067] Figure 1 It is a flow chart of a small target detection method based on improved YOLOv8 provided in an embodiment of the present invention.
[0068] Figure 2 It is a structural block diagram of a small target detection system based on improved YOLOv8 provided in an embodiment of the present invention.
[0069] Figure 3 It is a network structure diagram of an improved YOLOv8 model provided by an embodiment of the present invention.
[0070] Figure 4 It is a structural diagram of the EMA attention mechanism provided by an embodiment of the present invention.
[0071] Figure 5 This is a diagram of a dynamic snake-shaped convolution structure provided by an embodiment of the present invention.
[0072] Figure 6 It is a schematic diagram of Inner-IoU provided by an embodiment of the present invention.
[0073] Figure 7 It is a comparison chart of small target detection results in three different fields provided by an embodiment of the present invention.
[0074] Figure 8 It is a flow chart of a small target detection system provided by an embodiment of the present invention.
[0075] Fig. 9 This is a diagram of camera detection effects of a small target detection system provided by an embodiment of the present invention.
[0076] Fig.10 This is a picture detection effect diagram of the small target detection system provided by an embodiment of the present invention.
[0077] Fig.11 This is a dual-screen detection effect diagram of a small target detection system provided by an embodiment of the present invention.
[0078] Fig.12 It is a diagram of the training process of the accuracy P in the improved YOLOv8 model provided in an embodiment of the present invention.
[0079] Fig.13 It is a diagram of the training process of the recall rate R in the improved YOLOv8 model provided in an embodiment of the present invention.
[0080] Fig.14 It is a graph of various indicators during the training process of the improved YOLOv8 model provided by an embodiment of the present invention.
[0081] Fig.15 This is an experimental comparison chart of the improved YOLOv8 model provided by an embodiment of the present invention and other classic models.
[0082] Fig.16 It is an experimental comparison chart of the improved YOLOv8 model provided by an embodiment of the present invention and the original model in different data sets. DETAILED DESCRIPTION
[0083] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.
[0084] The following are two specific industrial application examples of the small target detection method based on the improved YOLOv8:
[0085] 1) Transmission line fault detection during drone inspection
[0086] In power inspections, transmission line faults (such as broken wires and insulator cracks) are usually small targets with complex backgrounds and relatively small target sizes, making it difficult for traditional detection methods to effectively identify them.
[0087] 1) EMA module: Enhances the ability to capture multi-scale features of transmission lines and their accessories, and improves the detection sensitivity of small target fault areas.
[0088] 2) C2f_DSConv module: optimizes feature extraction efficiency and supports real-time processing when the computing resources on the drone are limited.
[0089] 3) Inner-ShapeIoU: More accurately regress the boundaries of the fault area and locate small cracks, breakages and other anomalies on the transmission line.
[0090] Achieve efficient and accurate transmission line fault detection, improve power inspection efficiency and safety, and reduce the risks and costs of manual inspections.
[0091] 2) Non-motor vehicle violation detection in intelligent transportation system
[0092] In urban road monitoring, the detection of illegal behaviors of non-motor vehicles (such as bicycles and electric vehicles) belongs to the small target detection task. Especially in dense traffic or complex backgrounds, traditional methods are prone to missed detection or false detection.
[0093] 1) EMA module: Enhances the recognition capability of small-target non-motor vehicles and their behavioral characteristics in dynamic backgrounds, and captures details of illegal behaviors (such as crossing the line and driving against the flow).
[0094] 2) C2f_DSConv module: Improves the real-time processing performance of the model and supports large-scale deployment of traffic cameras and real-time detection requirements.
[0095] 3) Inner-ShapeIoU: Accurately fit the bounding box position of non-motor vehicles to improve the accuracy of target boundary judgment.
[0096] Effectively improve the accuracy of non-motor vehicle violation detection, support traffic management departments in real-time monitoring and law enforcement, and improve urban traffic order.
[0097] These two embodiments demonstrate the wide application value of the present invention in industry and public services, and significantly improve the efficiency and accuracy in small target detection tasks.
[0098] like Figure 1 As shown, a small target detection method based on improved YOLOv8 provided by an embodiment of the present invention includes the following steps:
[0099] S101, a new EMA module is added after the SPPF module of the original YOLOv8 model: instead of the traditional downsampling method, all pixel-level information in each channel dimension is fully obtained to enhance the capture of small target information;
[0100] S102, introduce DSConv convolution into C2f convolution in the original YOLOv8 model, and partially replace the original C2f module with C2f_DSConv module;
[0101] S103, replace the CIoU loss function used in the original YOLOv8 model with Inner-ShapeIoU.
[0102] The following is the detailed working principle of the small target detection method based on the improved YOLOv8, which is divided into four sections:
[0103] In step S101, the newly designed EMA (Enhanced Multi-scale Attention) module is added to the SPPF module of the original YOLOv8 model. The traditional downsampling method will cause the small target information to be lost during the feature extraction process, while the EMA module can fully capture all pixel-level information in the channel dimension to achieve efficient fusion of multi-scale features. This module can focus on strengthening the information of small target areas, so that the model has higher perception and accuracy when detecting small targets.
[0104] In step S102, the DSConv (Depthwise Separable Convolution) convolution is introduced into the C2f convolution of the original model, and some C2f modules are replaced with C2f_DSConv modules. DSConv greatly reduces the computational complexity of convolution operations through separation convolution operations, while retaining the ability to separate and extract spatial features and channel features. This improvement optimizes the model's extraction efficiency for small target features, improving detection performance while reducing computing resource consumption.
[0105] In step S103, the CIoU (CompleteIoU) loss function used by the original YOLOv8 model is replaced with the newly designed Inner-ShapeIoU loss function. Inner-ShapeIoU more accurately describes the positioning error of small targets by focusing on the internal area and shape similarity of the target border, solving the problem of low regression accuracy of small targets by traditional loss functions. This improvement improves the positioning accuracy and boundary fitting ability of small targets in complex scenes.
[0106] Through the integration of the above improved modules, the improved YOLOv8 model shows significant performance improvement in small target detection. The EMA module enhances the ability to capture multi-scale features, the C2f_DSConv module improves the efficiency of feature extraction, and the Inner-ShapeIoU loss function optimizes the accuracy of bounding box regression. Through end-to-end training, the model achieves higher detection accuracy, recall rate and real-time performance in small target detection tasks, and is suitable for small target detection tasks in a variety of complex scenarios.
[0107] The EMA module provided by the embodiment of the present invention:
[0108] Assume any original input tensor X∈R C×H×W, where C represents the number of input channels, H and W represent the spatial dimensions of the input features respectively; in order to capture the relationship between channels, EMA adopts a parallel substructure consisting of two 1×1 branches and one 3×3 branch to extract the attention weight descriptor of the grouped feature map; in order to learn different semantics, EMA divides X into G sub-features in the channel dimension direction, with X=[X0,X i ,…X G-1 ],R C / / G×H×W In the form of, without loss of generality, let G<<C, and assume that the learned attention weight descriptor will be used to enhance the feature representation of the region of interest in each sub-feature; the 1×1 branch realizes cross-channel interaction features, and two one-dimensional global average pooling is used to encode the channels in two spatial directions. The one-dimensional global average pooling output in the horizontal dimension and the vertical dimension is shown in equations (1) and (2);
[0109]
[0110] Among them, x c is the input feature of the cth channel, i and j represent the position of the feature in the horizontal direction W and the vertical direction H respectively. as well as is the global average pooling output;
[0111] The 3×3 branch captures local cross-channel interactions through 3×3 convolution to expand the feature space; in EMA, two-dimensional global average pooling is used to encode the global spatial information of the output of the 1×1 branch, and the output of the smallest branch is directly converted into the corresponding dimensional shape before the channel feature joint activation mechanism, that is, Use two-dimensional global average pooling for different branches, see formula (3);
[0112]
[0113] Among them, x c is the input feature of the cth channel, (i, j) represents the location of the feature, Z c Represents the 2D global average pooling output.
[0114] The C2f_DSConv module provided in the embodiment of the present invention:
[0115] Given a standard 2D convolution coordinate K, the center coordinate is K i =(x i ,y i ); then a 3×3 convolution kernel K is shown in formula (4);
[0116] K={(x-1,y-1),(x-1,y),…,(x+1,y+1)} (4)
[0117] In dynamic snake convolution, the standard convolution is linearized in the x-axis and y-axis directions; a 9×9 convolution kernel is used. Taking the x-axis direction as an example, each specific position of the convolution kernel can be expressed as K i±c =(x i±c ,y i±c ), where c = {0, 1, 2, 3, 4} represents the horizontal distance from the center grid of the convolution kernel, K i±c It is a cumulative process, starting from the center position K i Initially, the position of the grid away from the center depends on the position of the previous grid: K i+1 Relative to K i An offset Δ={δ|δ∈[-1,1]} is added; in the process of changing along the x-axis, the offset Δ will be continuously accumulated, so as to ensure that the receptive field of the convolution kernel forms a continuous linear morphological structure; the process of changing along the y-axis is similar to that along the x-axis, that is, the x-shaped convolution on the right is formed; the maximum value of the horizontal offset c of the center grid is 4, then the standard convolution kernel can be obtained after multiple iterations. The expressions in the x-axis direction and the y-axis direction are shown in equations (5) and (6);
[0118]
[0119] Since the offset Δ is usually a decimal, and the coordinates are integers, the bilinear interpolation method is used, as shown in formula (7);
[0120] K=Σ K' B(K',K)·K' (7)
[0121] Where K is the position of the decimal format in equations (5) and (6), K' lists all the positions of the integer format, and B is the bilinear interpolation kernel, which can be decomposed into two one-dimensional kernels, as shown in equation (8);
[0122] B(K,K')=b(K x ,K' x )·b(K y ,K' y ) (8)
[0123] Among them, K x 'And K' y Respectively represent the integer positions in the x-axis direction and the y-axis direction, K x With K y Respectively represent the position of the target decimal format in the x-axis direction and the y-axis direction.
[0124] Inner-ShapeIoU provided by the embodiment of the present invention:
[0125] The bounding box regression loss function is an important part of object detection. The accuracy of object detection depends on it to a large extent. The loss function used by YOLOv8 is CIoU, which is calculated as shown in equations (9), (10), and (11);
[0126]
[0127] Among them, ρ 2 *(B,B gt ) is used to represent the center point B of the predicted box and the center point B of the real box gt The Euclidean distance between the two boxes, c is the diagonal length of the minimum enclosing rectangle covering the two boxes, and h is gt 、w gt ,h,w,are the height and width of the real box and the predicted box respectively, ν is used to measure the similarity of aspect ratio, and α is used as the weight coefficient;
[0128] Inner-IoU introduces a scaling factor ratio to control the size of the auxiliary box for calculating the loss. The definition of Inner-IoU is shown in equations (12)-(18);
[0129]
[0130]
[0131] union=(w gt *h gt )*(ratio) 2 +(w*h)*(ratio) 2 -inter, (17)
[0132]
[0133] Among them, the center points of the real box and the inner-real box are Indicates that the center point of the prediction box and the inner-prediction box is (x c ,y c ) indicates that the width and height of the real box are represented by w gt and h gt , the width and height of the prediction box are represented as w and h respectively, inter is the area of the middle red area, union is the union area of the auxiliary borders, and ratio, that is, the proportional factor, is generally [0.5, 1.5];
[0134] Adding Shape-IoU enables the model to focus on the shape and scale of the bounding box itself to calculate the loss function, making the bounding box regression more accurate. Its definition is shown in equations (19)-(23);
[0135]
[0136]
[0137] Ω shape =Σ t=w,h (1-e -ωt ) θ ,θ=4 (22)
[0138]
[0139] Among them, scale is the scaling factor and is related to the scale of the target in the dataset, ww and hh represent the weight coefficients in the horizontal and vertical directions respectively, and their values are related to the shape of the true box, and c is the distance between the center point of the true box and the center point of the predicted box. The improved Inner-ShapeIoU is shown in formula (24);
[0140] L Shape-IoU inner =1-IoU inner +distance shape +0.5*Ω shape
[0141] (twenty four).
[0142] like Figure 2 As shown, a small target detection system based on improved YOLOv8 provided by an embodiment of the present invention includes:
[0143] A module is added to add a new EMA module after the SPPF module of the original YOLOv8 model: instead of the traditional downsampling method, it completely obtains all pixel-level information in each channel dimension and enhances the capture of small target information;
[0144] The import module is used to introduce DSConv convolution into C2f convolution in the original YOLOv8 model, and partially replace the original C2f module with the C2f_DSConv module;
[0145] The replacement module is used to replace the CIoU loss function used in the original YOLOv8 model with Inner-ShapeIoU.
[0146] The system optimizes the model through the synergy of adding modules, introducing modules and replacing modules. The adding module adds the EMA (Enhanced Multi-scale Attention) module after the SPPF module of the original YOLOv8 model to capture all pixel-level information in the channel dimension, replacing the traditional downsampling method and enhancing the feature extraction capability of small targets; the introducing module introduces the DSConv (Depthwise Separable Convolution) convolution into the C2f convolution structure, replacing some C2f modules with C2f_DSConv modules, optimizing the efficiency of the convolution operation, reducing the computational complexity, and retaining the feature separation capability; the replacing module replaces the CIoU (Complete IoU) loss function with Inner-ShapeIoU, enhancing the regression accuracy of the small target border position.
[0147] The computer device runs the program stored in the computer-readable storage medium through the efficient collaboration of the memory and the processor to realize the above system functions. The memory saves the model optimization steps and parameter settings, and the processor performs specific computing tasks, including EMA module feature enhancement, C2f_DSConv module efficient convolution, Inner-ShapeIoU loss optimization and other operations to ensure that the model runs efficiently during training and reasoning. The system can dynamically adjust the optimization strategy to adapt to a variety of small target detection tasks.
[0148] The storage medium contains a compiled computer program that can be loaded and run by the device. When the program is executed, the control processor completes all steps of the small target detection method based on the improved YOLOv8, including data processing, model optimization and small target detection. The design of the storage medium ensures that the program can be migrated and executed in different devices, supports multi-scenario applications, and improves the flexibility and portability of the system.
[0149] The information data processing terminal integrates the above-mentioned improved YOLOv8 model and related modules, providing a complete small target detection solution. The terminal can be directly connected to cameras, sensors or other data sources to acquire and process image data in real time. Through the operation of the terminal, the system can efficiently complete the entire process from data input to the output of small target detection results. It is suitable for a variety of practical application scenarios such as drone inspections, traffic monitoring, industrial quality inspection, etc., reflecting the real-time, accuracy and versatility of the system.
[0150] The purpose of the present invention is to effectively solve the problems of missed detection and false detection of objects in small target scenes due to occlusion, complex background and other reasons. The present invention proposes an improved YOLOv8 algorithm. First, the EMA attention mechanism is introduced to dynamically adjust the weights in the feature map, capture the pixel-level paired relationship, retain the information on each channel and reduce the computational load, so that the model can better capture the characteristics of small targets. Secondly, the dynamic snake convolution DSConv is combined with C2f, and the model maintains continuous attention to small objects and complex local features through deformation offset, thereby enhancing the flexibility of the receptive field. Finally, the loss function is replaced with Inner-ShapeIoU, and shape-related loss terms and internal intersection-over-union ratio are introduced to improve the positioning accuracy and accelerate the convergence of the model, thereby enhancing the generalization ability of the model. Experimental results show that on multiple public data sets, the improved detection algorithm has improved the accuracy and recall rate of small target detection compared with the original YOLOv8 model, and can improve the related problems of the original model to a certain extent.
[0151] Original YOLOv8 model steps:
[0152] Step 1. Image data preprocessing: resize the image to a uniform size and perform data augmentation;
[0153] Step 2. Feature extraction in BackBone: It goes through CBS, C2f, and SPPF modules in sequence, and extracts multi-scale features through a series of convolutions;
[0154] Step 3. Feature fusion in the Neck part: Upsample and Concat modules are used together to fuse shallow and deep features, retain high-resolution information, and enhance context expression capabilities;
[0155] Step 4. The Prediction part gives the prediction results: the three detection heads give the results of target detection at different scales, such as category, location box and confidence level;
[0156] Step 5. NMS performs post-processing: non-maximum suppression is applied to remove redundant boxes, retain the target box with the highest confidence, and obtain the final output result.
[0157] In the actual use of the YOLOv8 target detection algorithm, the algorithm can better identify medium and large targets. However, in application scenarios with many small targets, the model cannot detect small targets well because the small targets have less information and are easily lost in subsequent downsampling and feature fusion, resulting in missed detections and false detections.
[0158] To this end, the present invention mainly focuses on the direction of better extracting small target features so as to correctly identify small target objects, and designs a target detection method based on improved YOLOv8 that is more conducive to small target scenes.
[0159] Improve the steps added to the original model of the YOLOv8 small target detection algorithm:
[0160] Step 1. Add a new EMA module after the SPPF module of the original YOLOv8 model: instead of the traditional downsampling method, it can fully obtain all pixel-level information in each channel dimension and enhance the capture of small target information;
[0161] Step 2. Introduce DSConv convolution into C2f convolution in the original YOLOv8 model, and partially replace the original C2f module with the C2f_DSConv module: This allows the model to flexibly adapt to the geometric changes of the target during feature extraction and enhance the flexibility of the receptive field;
[0162] Step 3. Replace the CIoU loss function used in the original YOLOv8 model with Inner-ShapeIoU: This effectively alleviates some limitations of CIOU in small target scenarios, strengthens the ability to detect small targets, accelerates the convergence of the model, and improves the generalization ability of the model.
[0163] Model structure of small target detection based on improved YOLOv8 Figure 3 .
[0164] Improvement point 1: Introducing EMA attention mechanism
[0165] EMA is an efficient multi-scale attention module (Efficient MultiScale Attention, EMA), which aims to retain information on each channel and reduce the computational load. It dynamically adjusts the weights in the feature map in an adaptive manner according to the importance of each area, allowing the network to focus on small target parts. EMA reshapes some channels into batch dimensions and groups the channel dimensions into multiple sub-features so that the spatial semantic features are evenly distributed within each feature group. Specifically, EMA not only encodes global information to recalibrate the channel weights in each parallel branch, but the output features of the two parallel branches are further aggregated through cross-dimensional interactions to capture pairwise relationships at the pixel level. The structure of the attention mechanism EMA is shown in the figure. Figure 4 shown.
[0166] Assume any original input tensor X∈R C×H×W , where C represents the number of input channels, H and W represent the spatial dimensions of the input features. In order to capture the relationship between channels, EMA adopts a parallel substructure consisting of two 1×1 branches and one 3×3 branch to extract the attention weight descriptor of the grouped feature map. In order to learn different semantics, EMA divides X into G sub-features in the channel dimension direction, with X = [X0, X i ,…XG-1 ],R C / / G×H×W In the form of , without loss of generality, let G < < C, and assume that the learned attention weight descriptor will be used to enhance the feature representation of the region of interest in each sub-feature. The 1×1 branch realizes cross-channel interaction features, and two one-dimensional global average poolings are used to encode the channels in two spatial directions. The one-dimensional global average pooling outputs in the horizontal and vertical dimensions are shown in Equations (1) and (2).
[0167]
[0168] Among them, x c is the input feature of the cth channel, i and j represent the position of the feature in the horizontal direction W and the vertical direction H respectively. as well as is the global average pooling output.
[0169] The 3×3 branch captures local cross-channel interactions through 3×3 convolution to expand the feature space. In EMA, two-dimensional global average pooling is used to encode the global spatial information of the output of the 1×1 branch. Before the channel feature joint activation mechanism, the output of the smallest branch is directly converted into the corresponding dimensional shape, that is, Two-dimensional global average pooling is used for different branches, see formula (3).
[0170]
[0171] Among them, x c is the input feature of the cth channel, (i, j) represents the location of the feature, Z c Represents the 2D global average pooling output.
[0172] In the EMA module, a cross-spatial information aggregation method is used to achieve richer feature aggregation in different spatial dimensions. The outputs of the 1×1 and 3×3 branches are encoded with global spatial information using two-dimensional global average pooling and converted into corresponding dimensional shapes respectively. The first spatial attention map is generated by matrix dot product operation, and the second spatial attention map is generated while maintaining the precise spatial position information. Finally, through the aggregation of the two generated spatial attention weight values and the Sigmoid function, the pixel-level pairwise relationship is captured, the global context information is highlighted, and the output is the same size as the input, which is efficient and suitable for integration into modern architectures.
[0173] The EMA attention mechanism has significant advantages in small target detection. By combining global and local feature descriptors, EMA is able to capture pixel-level pairwise relationships and emphasize global context, focusing on extracting features of smaller targets, thereby improving the precision and accuracy of detection. In small target detection, EMA performs particularly well when dealing with complex backgrounds and occluded targets, and can significantly improve the average precision. In addition, EMA's lightweight design only adds a small amount of parameters and computation, making it particularly suitable for small target detection in resource-constrained environments, such as deployment on mobile devices, and has high practical application value. This not only improves the performance of small target detection, but also ensures efficient calculation and low resource consumption of the model.
[0174] Improvement 2: Modify the original C2f module, add DSConv convolution, and design it into C2f_DSConv module
[0175] Dynamic Snake Convolution (DSConv) is an emerging convolution structure. Its design is inspired by the snake-like data path and aims to enhance the network's ability to process images with irregular shapes and complex textures. Compared with traditional convolution, dynamic snake convolution can more efficiently capture details and local features in images by changing the movement path. By introducing deformation offset on the basis of the standard convolution kernel, it can flexibly adapt to the geometric changes of the target. Specifically, DSConv adopts an iterative strategy to adjust the receptive field of the convolution kernel along the morphological changes of the target, thereby maintaining continuous attention to the local features of the target. Unlike traditional deformable convolution, DSConv combines constraints on the target morphology while freely learning the deformation offset, ensuring accurate capture of slender and curved features. The principle of DSConv is as follows Figure 5 shown.
[0176] Given a standard 2D convolution coordinate K, the center coordinate is K i =(x i ,y i ). Then a 3×3 convolution kernel K is shown in formula (4).
[0177] K={(x-1,y-1),(x-1,y),…,(x+1,y+1)} (4)
[0178] In the dynamic snake convolution, the standard convolution is linearized in the x-axis and y-axis directions. The present invention uses a 9×9 convolution kernel. Taking the x-axis direction as an example, each specific position of the convolution kernel can be expressed as K i±c =(x i±c ,y i±c ), where c = {0, 1, 2, 3, 4} represents the horizontal distance from the center grid of the convolution kernel, K i±cIt is a cumulative process, starting from the center position K i Initially, the position of the grid away from the center depends on the position of the previous grid: K i+1 Relative to K i An offset Δ={δ|δ∈[-1,1]} is added. In the process of changing along the x-axis, the offset Δ will continue to accumulate, thereby ensuring that the receptive field of the convolution kernel forms a continuous linear morphological structure; the process of changing along the y-axis is similar to that along the x-axis, that is, forming an x-shaped convolution on the right. The maximum value of the horizontal offset c of the center grid is 4, then the standard convolution kernel can be obtained after multiple iterations. The expressions in the x-axis and y-axis directions are shown in equations (5) and (6).
[0179]
[0180] Since the offset Δ is usually a decimal and the coordinates are integers, the bilinear interpolation method is used, as shown in formula (7).
[0181] K=Σ K' B(K',K)·K' (7)
[0182] Where K is the position of the decimal format in equations (5) and (6), K' lists all the positions of the integer format, and B is the bilinear interpolation kernel, which can be decomposed into two one-dimensional kernels, as shown in equation (8).
[0183] B(K,K')=b(K x ,K' x )·b(K y ,K' y ) (8)
[0184] Among them, K x 'And K' y Respectively represent the integer positions in the x-axis direction and the y-axis direction, K x With K y Respectively represent the position of the target decimal format in the x-axis direction and the y-axis direction.
[0185] Dynamic Snake Convolution (DSConv) straightens the standard convolution kernel on the x-axis and y-axis and introduces deformation offset, so that the convolution kernel can flexibly focus on the complex geometric features of the target. An iterative strategy is adopted to ensure the continuity of attention, and the fractional offset is processed by bilinear interpolation to achieve effective extraction of local features of tubular structures.
[0186] The present invention adds DSConv to the small target detection algorithm based on YOLOv8, which has the following benefits: improving feature extraction capability: DSConv can adapt to complex geometric forms, especially for more accurate extraction of complex local features; enhancing the flexibility of the receptive field: by introducing deformation offset and iteration strategy, DSConv can flexibly adjust the receptive field, avoiding the problem of over-expansion of the receptive field of standard convolution when processing complex scenes; improving detection continuity: the strategy adopted by DSConv can ensure the continuity of attention and reduce the problem of discontinuity of the receptive field caused by deformation offset; strong adaptability: DSConv can adaptively adjust the shape of the convolution kernel according to the input features, so as to better capture the small target features in complex scenes and improve the robustness and accuracy of detection. In summary, DSConv can effectively alleviate the problems of inaccurate feature extraction, inflexible receptive field, discontinuous detection results, etc. in small target detection, thereby improving the overall detection performance.
[0187] Improvement point 3: Replace the original CIoU loss function with Inner-ShapeIoU
[0188] The bounding box regression loss function is an important part of object detection. The accuracy of object detection depends on it to a large extent. The loss function used by YOLOv8 is CIoU, which is calculated as shown in Equations (9), (10), and (11).
[0189]
[0190]
[0191] Among them, ρ 2 *(B,B gt ) is used to represent the center point B of the predicted box and the center point B of the real box gt The Euclidean distance between them, c is the diagonal length of the smallest circumscribed rectangle covering the two boxes, ν is used to measure the similarity of aspect ratios, and α is used as a weight coefficient. Although CIoU improves the accuracy of regression, there are some smaller targets in image detection, and smaller w and h will cause the bounding box regression of CIoU to be disturbed, thus failing to reflect the real situation.
[0192] Inner-IoU greatly improves the fitting accuracy of the target boundary by introducing shape-related loss terms and internal intersection-over-union ratio. In small target detection, targets often have strong occlusion, overlap and morphological diversity, and traditional loss functions are prone to errors when dealing with these complex situations. Inner-IoU calculates shape weight coefficients and shape distances, so that the predicted box can better match the shape of the real target, thereby effectively distinguishing overlapping small targets and improving the positioning accuracy of the detection box; secondly, Inner-IoU can accelerate the convergence process of the model. By introducing auxiliary bounding boxes to calculate losses, high IoU samples can adjust the bounding boxes more quickly during training, and the model can achieve higher detection accuracy faster; thirdly, Inner-IoU introduces auxiliary bounding boxes of different scales to calculate losses, making the model more stable in different scenarios, and can effectively cope with the high diversity in various small target detection scenarios, including different shooting angles, lighting conditions and target densities, overcoming the problem of insufficient generalization ability of existing methods in different data sets and detectors. In Inner-IoU, a scaling factor ratio is introduced to use auxiliary bounding boxes of different scales for different datasets and detectors. Figure 6 As shown in the figure, the Inner-IoU calculation method at smaller and larger scales is shown respectively.
[0193] Inner-IoU introduces a scaling factor ratio to control the size of the auxiliary box for calculating the loss. The definition of Inner-IoU is shown in equations (12)-(18).
[0194]
[0195]
[0196] union=(w gt *h gt )*(ratio) 2 +(w*h)*(ratio) 2 -inter, (17)
[0197]
[0198] Among them, the center points of the real box and the inner-real box are Indicates that the center point of the prediction box and the inner-prediction box is (x c ,y c ) indicates that the width and height of the real box are represented by w gt and h gt, the width and height of the predicted box are represented as w and h respectively, inter is the area of the middle red area, union is the union area of the auxiliary bounding boxes, and ratio is the scaling factor, which is generally [0.5, 1.5]. When ratio < 1, the auxiliary bounding box is smaller than the actual bounding box, which helps to speed up the regression and convergence of high IoU samples, such as Figure 6 Middle left image; On the contrary, when ratio>1, the auxiliary bounding box is larger, which can speed up the regression process of low IoU samples, such as Figure 6 Middle right picture.
[0199] Adding Shape-IoU enables the model to focus on the shape and scale of the bounding box itself to calculate the loss function, making the bounding box regression more accurate. Its definition is shown in Equations (19)-(23).
[0200]
[0201] Ω shape =Σ t=w,h (1-e -ωt ) θ ,θ=4 (22)
[0202]
[0203] Among them, scale is the scaling factor and is related to the scale of the target in the dataset, ww and hh represent the weight coefficients in the horizontal and vertical directions respectively, and their values are related to the shape of the real box, and c is the distance between the center point of the real box and the center point of the predicted box. Shape-IoU is combined to improve Inner-IoU, replacing the calculation part of IoU. Combining the advantages of Inner-IoU and ShapeIoU, while speeding up the regression process of the bounding box, the bounding box regression is made more accurate, which can make the model better adapt to the characteristics of small targets and enhance the generalization ability of the model in the face of small targets. The improved Inner-ShapeIoU is shown in formula (24).
[0204] L Shape-IoU inner =1-IoU inner +distance shape +0.5*Ω shape (twenty four)
[0206] In summary, the use of Inner-ShapeIoU in YOLOv8 has significant advantages in small target detection, which not only improves positioning accuracy and accelerates model convergence, but also enhances the detection ability of small targets and the generalization ability of the model. These improvements effectively alleviate the problems of overlapping targets in small target detection, long training time, low small target detection accuracy, and unstable performance of the model in different scenarios, which fully demonstrates the necessity of applying Inner-ShapeIoU on small target datasets.
[0207] Finally, the present invention verifies through experiments that the original YOLOv8 model has the shortcomings described in Section 2 when applied to small target detection, and that the improved algorithm based on YOLOv8 can solve these shortcomings in a targeted manner. The experimental results are shown in the following table. The present invention experiment uses data sets of small targets in three different fields. By comparing the accuracy, the effect of the improved algorithm can be intuitively reflected.
[0208] Table 1 Ablation experiment results on WiderPerson dataset
[0209]
[0210] Table 2 Experimental results on different datasets
[0211]
[0212] According to Table 1, after adding the EMA mechanism, the model is more focused on capturing local features, and the overall performance has been improved to a certain extent, among which the accuracy and recall of the model have increased by 1.0% and 0.9% respectively; after adding the DSConv dynamic snake convolution, the flexibility of the model's receptive field is enhanced, but the accuracy is improved while the computational load is also increased, and the number of parameters and the amount of computation of the model have increased; after adding the Inner-ShapeIoU, the regression accuracy of the bounding box is enhanced, and all indicators have been improved to a certain extent, especially mAP50 and mAP50:95, which have increased by 1.9% and 2.4% respectively; when the subsequent modules are combined, due to the characteristics of each module, the impact on each performance is good and bad. Compared with the original YOLOv8 model, the detection accuracy and recall of the algorithm in this paper reached 88.2% and 81.3%, respectively, an increase of 2.1% and 1.7%.
[0213] According to Table 2, the accuracy of the present invention in three different field datasets, namely, drone image small target dataset (VisDrone2019), traffic sign dataset (TT100K) and dense pedestrian dataset (WiderPerson), is improved compared with the original YOLOv8 model. The improved YOLOv8 algorithm effectively solves the problem of small target detection by introducing methods such as EMA attention mechanism and DSConv. The EMA attention mechanism can focus the network on the feature extraction of small targets by dynamically adjusting the weights of feature maps, improves the detection accuracy of small targets, and avoids the neglect of small target information by traditional convolution. In addition, DSConv can accurately capture the details of small targets in complex scenes by adaptively adjusting the receptive field, especially under the condition of small targets and complex backgrounds or occlusion, and can still maintain high detection performance. In order to further improve the robustness of the algorithm in small target detection, the present invention optimizes the loss function and introduces shape-related loss terms to ensure that the boundaries of small targets can be more accurately fitted, thereby improving the target positioning accuracy.
[0214] Experimental results show that the improved YOLOv8 proposed in the present invention is applied to small target detection, which effectively solves the accuracy and robustness problems of small target detection and enables the algorithm to maintain good generalization ability and efficient calculation in various complex scenarios.
[0215] Figure 7 These are practical application examples of the method of the present invention in three different fields. The first picture is a picture from the VisDrone2019 dataset, the second picture is a picture from the WiderPerson dataset, and the third picture is a picture from the TT100K dataset. The picture on the left is the original YOLOv8 model, and the picture on the right is the improved YOLOv8 model of the present invention. It can be clearly seen that the original YOLOv8 model in the picture on the left will have some missed detection problems, and the optimized model can more accurately detect small targets that are blocked and missed. These experimental results all show that the improved algorithm is more suitable for detecting small target images.
[0216] The small target detection system of the present invention is developed based on the improved YOLOv8 model of the present invention, and is optimized for the small target detection task. The improved algorithm is more suitable for small target image detection. The system supports turning on the camera for real-time detection, uploading pictures or videos for detection, and selecting different small target data sets for training models. The system also integrates a series of advanced functions to improve the user experience and detection efficiency. The user can display the detection screen and the original screen simultaneously or separately in the detection screen, which is convenient for intuitively comparing the detection results with the actual situation. Through the clickable drop-down box, the user can mark specific targets separately and display the results, which is extremely useful for users who are concerned about specific types of targets. All detection results will be displayed in the table of the page, and the user can also dynamically adjust the confidence threshold and IOU threshold of the detection algorithm as needed to optimize the accuracy and recall rate of the detection results. The system aims to provide users with a comprehensive, flexible and easy-to-use small target detection tool to meet the small target detection needs of different users in different application scenarios.
[0217] Figure 8 This is the overall flow chart of this system. Fig. 9 The test file is the real-time monitoring of the camera image. Fig.10 This is the detection effect of the model trained using the face dataset. The test file is a picture, and the location and other information are shown in the figure. Fig.11 This is the detection effect of the model trained using the mask detection dataset. The test file is a picture, and a dual-screen display is used for contrast.
[0218] In order to verify the effectiveness of the improved YOLOv8 model, experiments were conducted on different datasets, including dense pedestrian detection datasets, traffic sign datasets, and drone datasets. The experimental results show that the improved model has significantly improved the accuracy of small target detection compared to the original YOLOv8, especially in scenes with complex backgrounds, severe occlusion, and multi-scale targets. Whether it is the accuracy of target recognition, recall rate, or positioning accuracy of the bounding box, good results have been achieved, which fully verifies the stability and practicality of the improved model in practical applications.
[0219] Figure 12-14 This is the training process of the accuracy, recall, loss and other indicators in the training process of the dense pedestrian dataset WiderPerson of the present invention. Fig.15The figure shows the comparison of the precision P and recall rate R of the present invention with the classic models Faster R-CNN, YOLOv5n and YOLOv8n on dense pedestrian data sets. It can be seen from the figure that both P and R of the present invention have been improved, especially P, which has surpassed the other three models. Compared with Faster R-CNN, the present invention improves the model's recognition ability for dense targets and significantly reduces missed detection and false detection; compared with YOLOv5 and YOLOv8, the present invention further improves the accuracy of detection while maintaining a high recall rate. Fig.16 This is an experimental comparison chart of the present invention with the original YOLOv8 model in three data sets. It can be seen from the experimental result chart that the improved YOLOv8 model has achieved higher mAP on all three data sets. On the dense pedestrian data set, mAP has improved, indicating that the improved model performs better when dealing with dense targets and small targets; on the traffic sign data set, mAP has also improved to a certain extent, indicating that the model is more accurate in detecting small objects; on the drone data set, the mAP of the improved model is significantly better than the original YOLOv8 model, proving that it is more robust in complex scenes. Overall, the generalization ability and detection effect of the improved model on different data sets have been effectively verified.
[0220] It should be noted that the embodiments of the present invention can be implemented by hardware, software, or a combination of software and hardware. The hardware part can be implemented using dedicated logic; the software part can be stored in a memory and executed by an appropriate instruction execution system, such as a microprocessor or dedicated design hardware. It can be understood by a person of ordinary skill in the art that the above-mentioned devices and methods can be implemented using computer executable instructions and / or contained in a processor control code, such as a carrier medium such as a disk, CD or DVD-ROM, a programmable memory such as a read-only memory (firmware), or a data carrier such as an optical or electronic signal carrier. Such code is provided on the carrier medium. The device and its modules of the present invention can be implemented by hardware circuits such as very large-scale integrated circuits or gate arrays, semiconductors such as logic chips, transistors, etc., or programmable hardware devices such as field programmable gate arrays, programmable logic devices, etc., can also be implemented by software executed by various types of processors, and can also be implemented by a combination of the above-mentioned hardware circuits and software, such as firmware.
[0221] The above description is only a specific implementation mode of the present invention, but the protection scope of the present invention is not limited thereto. Any modifications, equivalent substitutions and improvements made by any technician familiar with the technical field within the technical scope disclosed by the present invention and within the spirit and principle of the present invention should be covered by the protection scope of the present invention.
Claims
1. A small target detection method based on improved YOLOv8, characterized in that: The following steps are involved: Step 1: Add the EMA module after the SPPF module of the original YOLOv8 model to capture all pixel-level information in the channel dimension; Step 2: Introduce DSConv convolution into the C2f convolution of the original YOLOv8 model, and replace part of the C2f module with the C2f_DSConv module; Step 3: Replace the CIoU loss function used in the original YOLOv8 model with the Inner-ShapeIoU loss function; Step 4: Integrate the above improved modules through end-to-end training to build a small target detection model.
2. The small target detection method according to claim 1, characterized in that: The EMA module allocates attention to all pixel information in the channel dimension on a multi-scale feature map to enhance the ability to capture information in small target areas.
3. The small target detection method based on improved YOLOv8 as claimed in claim 1, characterized in that: The EMA module: Assume any original input tensor X∈R C×H×W , where C represents the number of input channels, H and W represent the spatial dimensions of the input features respectively; in order to capture the relationship between channels, EMA adopts a parallel substructure consisting of two 1×1 branches and one 3×3 branch to extract the attention weight descriptor of the grouped feature map; in order to learn different semantics, EMA divides X into G sub-features in the channel dimension direction, with X=[X0,X i ,…X G-1 ],R C / / G×H×W In the form of, without loss of generality, let G < < C, and assume that the learned attention weight descriptor will be used to enhance the feature representation of the region of interest in each sub-feature; The 1×1 branch realizes cross-channel interaction features, and uses two one-dimensional global average pooling to encode channels in two spatial directions. The one-dimensional global average pooling output in the horizontal and vertical dimensions is shown in equations (1) and (2). Among them, x c is the input feature of the cth channel, i and j represent the position of the feature in the horizontal direction W and the vertical direction H respectively. as well as is the global average pooling output; The 3×3 branch captures local cross-channel interactions through 3×3 convolution to expand the feature space; in EMA, two-dimensional global average pooling is used to encode the global spatial information of the output of the 1×1 branch, and the output of the smallest branch is directly converted into the corresponding dimensional shape before the channel feature joint activation mechanism, that is, Use two-dimensional global average pooling for different branches, see formula (3); Among them, x c is the input feature of the cth channel, (i, j) represents the location of the feature, Z c Represents the 2D global average pooling output.
4. The small target detection method based on improved YOLOv8 as claimed in claim 1, characterized in that: The C2f_DSConv module: Given a standard 2D convolution coordinate K, the center coordinate is K i =(x i ,y i ); then a 3×3 convolution kernel K is shown in formula (4); K={(x-1,y-1),(x-1,y),…,(x+1,y+1)} (4) In dynamic snake convolution, the standard convolution is linearized in the x-axis and y-axis directions; a 9×9 convolution kernel is used. Taking the x-axis direction as an example, each specific position of the convolution kernel can be expressed as K i±c =(x i±c ,y i±c ), where c = {0, 1, 2, 3, 4} represents the horizontal distance from the center grid of the convolution kernel, K i±c It is a cumulative process, starting from the center position K i Initially, the position of the grid away from the center depends on the position of the previous grid: K i+1 Relative to K i An offset Δ={δ|δ∈[-1,1]} is added; in the process of changing along the x-axis, the offset Δ will be continuously accumulated to ensure that the receptive field of the convolution kernel forms a continuous linear morphological structure; the process of changing along the y-axis is similar to that along the x-axis, that is, the x-shaped convolution on the right is formed; the maximum value of the horizontal offset c of the center grid is 4, then the standard convolution kernel can be obtained after multiple iterations. 9×9 convolution kernel on the right; Its expressions in the x-axis direction and y-axis direction are shown in equations (5) and (6); Since the offset Δ is usually a decimal, and the coordinates are integers, the bilinear interpolation method is used, as shown in formula (7); K=Σ K' B(K',K)·K' (7) Where K is the position of the decimal format in equations (5) and (6), K' lists all the positions of the integer format, and B is the bilinear interpolation kernel, which can be decomposed into two one-dimensional kernels, as shown in equation (8); B(K,K')=b(K x ,K' x )·b(K y ,K' y ) (8) Among them, K x 'And K' y Respectively represent the integer positions in the x-axis direction and the y-axis direction, K x With K y Respectively represent the position of the target decimal format in the x-axis direction and the y-axis direction.
5. The small target detection method based on improved YOLOv8 as claimed in claim 1, characterized in that: The Inner-ShapeIoU: The bounding box regression loss function is an important part of object detection. The accuracy of object detection depends on it to a large extent. The loss function used by YOLOv8 is CIoU, which is calculated as shown in equations (9), (10), and (11); Among them, ρ 2 *(B,B gt ) is used to represent the center point B of the predicted box and the center point B of the real box gt The Euclidean distance between them, c is the diagonal length of the minimum circumscribed rectangle covering the two boxes, ν is used to measure the similarity of the aspect ratio, and α is used as the weight coefficient; Inner-IoU introduces a scaling factor ratio to control the size of the auxiliary box for calculating the loss. The definition of Inner-IoU is shown in equations (12)-(18); union=(w gt *h gt )*(ratio) 2 +(w*h)*(ratio) 2 -inter, (17) Among them, the center points of the real box and the inner-real box are Indicates that the center point of the prediction box and the inner-prediction box is (x c ,y c ) indicates that the width and height of the real box are represented by w gt and h gt , the width and height of the prediction box are represented as w and h respectively, inter is the area of the middle red area, union is the union area of the auxiliary borders, and ratio, that is, the proportional factor, is generally [0.5, 1.5]; Adding Shape-IoU enables the model to focus on the shape and scale of the bounding box itself to calculate the loss function, making the bounding box regression more accurate. Its definition is shown in equations (19)-(23); Oh shape =S t=w,h (1-e -ωt ) θ ,θ=4 (22) Among them, scale is the scaling factor and is related to the scale of the target in the dataset, ww and hh represent the weight coefficients in the horizontal and vertical directions respectively, and their values are related to the shape of the true box, and c is the distance between the center point of the true box and the center point of the predicted box. The improved Inner-ShapeIoU is shown in formula (24); L Shape-IoU inner =1-IoU inner +distance shape +0.5*Ω shape (24).
6. A small target detection system based on improved YOLOv8 that implements the small target detection method based on improved YOLOv8 as claimed in any one of claims 1 to 4, characterized in that: The small target detection system based on improved YOLOv8 includes: A module is added to add a new EMA module after the SPPF module of the original YOLOv8 model: instead of the traditional downsampling method, it completely obtains all pixel-level information in each channel dimension and enhances the capture of small target information; The import module is used to introduce DSConv convolution into C2f convolution in the original YOLOv8 model, and partially replace the original C2f module with the C2f_DSConv module; The replacement module is used to replace the CIoU loss function used in the original YOLOv8 model with Inner-ShapeIoU.
7. A computer device, characterized in that: The computer device includes a memory and a processor, the memory stores a computer program, and when the computer program is executed by the processor, the processor performs the steps of the small target detection method based on the improved YOLOv8 as described in any one of claims 1 to 5.
8. A computer-readable storage medium storing a computer program, wherein when the computer program is executed by a processor, the processor executes the steps of the small target detection method based on the improved YOLOv8 as described in any one of claims 1 to 5.
9. An information data processing terminal, characterized in that: The information data processing terminal is used to implement the small target detection system based on improved YOLOv8 as described in claim 6.
Citation Information
Patent Citations
Complex scene military target identification method based on improved YOLOv8
CN118470306A
Detection method for tiny complex target in aerial image of unmanned aerial vehicle
CN118865170A
Target identification model, transformer area on-site target identification method and system, and medium
CN119048733A
Cited By
Improved soybean seed test system and method based on YOLO v8
CN120451520A
Detection method suitable for small vascular bundle of rice stem section
CN120496063A