Improved multi-size target detection method, system, device and medium based on YOLOV7
By improving the Backbone, Neck, and Head networks of YOLOv7 and combining them with CBS, SIMAM, and RepConv modules, and employing a hybrid bounding box regression loss function, the detection accuracy and speed for small targets have been improved, thus solving the problem of YOLOv7's poor performance in detecting small targets with limited pixel information.
Patent Information
- Application Number
- CN202411587343.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-08
- Publication Date
- 2025-11-18
- Estimated Expiration
- 2044-11-08
AI Technical Summary
The existing YOLOv7 detection network performs poorly in detecting small targets with limited pixel information, especially in natural environments.
A multi-size target detection model based on YOLOv7 was constructed. The model uses a backbone network for four feature extractions, a neck network for feature fusion, and an output branch in the head network. The model combines CBS, SIMAM, and RepConv modules and employs a hybrid bounding box regression loss function to improve detection accuracy.
It improves the accuracy and speed of detecting small targets and solves the problem that YOLOv7 performs poorly when detecting small targets with few pixel information.
Smart Images

Figure CN119516169B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer vision technology, and in particular to a method, system, device and medium for multi-size target detection based on YOLOv7. Background Technology
[0002] In recent years, the application of various intelligent devices combining computer vision technology in modern agriculture has become increasingly widespread in agricultural production, and has become a research hotspot in the agricultural field. Specifically in apple production, deep learning-based object detection technology can identify apples, predict yield, and identify pests and diseases using images or videos taken by cameras or drones. It can also grade apples based on their quality using image information. These technologies have greatly promoted the intelligent development of apple production management. Among these, accurately identifying apples using object detection technology and then predicting yield is of great significance for orchard operation and management, providing fruit farmers with information on orchard yields.
[0003] Traditional techniques for crop yield estimation still suffer from several problems, such as unclear image boundaries due to sliding windows, complex target feature design, poor portability, and tedious manual design. Therefore, an increasing number of deep learning-based target detection algorithms are being applied to agricultural production. These algorithms can be broadly categorized into single-stage and two-stage algorithms based on their implementation flow. Classic two-stage target detection algorithms include R-CNN, Fast R-CNN, and Faster R-CNN. Compared to two-stage algorithms, single-stage algorithms involve less redundant computation, faster detection speed, and lower hardware performance requirements. Representative single-stage algorithms include the YOLOV series and SSD. Single-stage algorithms eliminate the step of generating candidate target regions, directly predicting the target category or location on the input image, significantly improving detection speed and thus gaining widespread application in agriculture.
[0004] Most existing apple number detection methods are based on experiments with static images. However, in natural environments, factors such as shooting distance and foliage obstruction can cause some target pixels to be too small when photographing apples, resulting in significant differences in the scale of different targets. Although YOLOv7 has three detection heads to detect large, medium, and small targets respectively, the detection effect is unsatisfactory for tiny targets with limited pixel information relying solely on these three detection heads. Summary of the Invention
[0005] The purpose of this invention is to provide a multi-size target detection method, system, device, and medium based on an improved YOLOv7, to solve the technical problem that the existing YOLOv7 detection network has poor performance in detecting small targets with limited pixel information.
[0006] To address the aforementioned technical problems, as one aspect of this invention, a multi-size target detection method based on an improved YOLOv7 is provided, comprising the following steps:
[0007] A multi-size target detection model based on an improved YOLOv7 is constructed. This model includes a Backbone network, a Neck network, and a Head network. The Backbone network performs four feature extractions on the feature map input to the model. The Neck network fuses the features extracted by the Backbone network to form four fusion branches, which are then input into the Head network to detect four targets of different sizes. The Head network outputs the detection results for the four targets of different sizes.
[0008] Train the multi-size target detection model;
[0009] The image to be detected is input into the multi-size target detection model after training, so that the multi-size target detection model outputs the target in the image to be detected that meets the size requirement;
[0010] The Backbone network comprises, in sequence, a CBS combining module, a first SIMAM combining module, a second SIMAM combining module, a third SIMAM combining module, and a fourth SIMAM combining module;
[0011] The first SIMAM combining module includes an ELAN module and a SIMAM module for initial feature extraction. The features extracted by the first SIMAM combining module are then input into the second SIMAM combining module and the Neck network.
[0012] The second SIMAM combining module includes an MPConv module, an ELAN module, and a SIMAM module for a second feature extraction. The features extracted by the second SIMAM combining module are input to the third SIMAM combining module and the Neck network, respectively.
[0013] The third SIMAM combining module includes an MPConv module, an ELAN module, and a SIMAM module for the third feature extraction. The features extracted by the third SIMAM combining module are respectively input into the fourth SIMAM combining module and the Neck network.
[0014] The fourth SIMAM combining module includes an MPConv module, an ELAN module, an SPPCSPC module, and a SIMAM module in sequence for extracting features for the fourth time and inputting the extracted features into the Neck network;
[0015] The CBS ensemble module includes four different CBS modules, which are used to change the size and number of feature maps; the ELAN module is an efficient layer aggregation network used for multi-scale feature extraction and fusion of images; the SIMAM module is used to incorporate a three-dimensional attention mechanism during feature extraction to improve the feature extraction capability of the multi-size object detection model network; the SIMAM modules in the four SIMAM ensemble modules all input the extracted features into the Neck network; the MPConv module is used for pooling the feature maps; and the SPPCSPC module is used to extract features after explicitation at different sizes.
[0016] Furthermore, the loss function of the multi-size target detection model is a hybrid bounding box regression loss function based on CIOU loss function and normalized Gaussian Wasserstein distance.
[0017] Furthermore, the expression for the hybrid bounding box regression loss function lbox is:
[0018] lbox=λ*NWD+(1-λ)CIOU
[0019] Where λ is the weighting factor and NWD is the normalized Gaussian Wasserstein distance.
[0020] Furthermore, the Neck network includes 2 first CBS modules, 2 second CBS modules, 2 third CBS modules, 1 fourth CBS module, 3 upsampling modules, 6 Concat modules, 6 Concat-Conv modules, and 3 MPConv modules;
[0021] Among them, the first CBS module, the second CBS module, the third CBS module, and the fourth CBS module are four different CBS modules; the Concat module is used to perform feature fusion in the channel dimension; and the Concat-Conv module is used to extract and fuse multi-scale features of the image.
[0022] Furthermore, the Head network includes a first-size detection head, a second-size detection head, a third-size detection head, and a fourth-size detection head; wherein, the first size > the second size > the third size > the fourth size;
[0023] The features extracted by the fourth SIMAM combining module are sequentially processed by the fourth CBS module, the first third CBS module, the first upsampling module, the first Concat module, the first Concat-Conv module, the second CBS module, the second upsampling module, the second Concat module, the second Concat-Conv module, the first CBS module, the third upsampling module, the third Concat module, and the third Concat-Conv module; the features extracted by the third SIMAM combining module are processed by the second third CBS module and the first Concat module; the features extracted by the second SIMAM combining module are processed by the second second CBS module and the second Concat module; the features extracted by the first SIMAM combining module are processed by the second first CBS module and the third Concat module; the output of the third Concat-Conv module serves as the input to the first size detection head.
[0024] The output of the third Concat-Conv module is then passed sequentially through the first MPConv module, the fourth Concat module, the fourth Concat-Conv module, the second MPConv module, the fifth Concat module, the fifth Concat-Conv module, the third MPConv module, the sixth Concat module, and the sixth Concat-Conv module; the output of the second Concat-Conv module also serves as the input of the fourth Concat module; the output of the first Concat-Conv module also serves as the input of the fifth Concat module; and the output of the fourth CBS module also serves as the input of the sixth Concat module.
[0025] The output of the fourth Concat-Conv module is also used as the input of the second size detection head; the output of the fifth Concat-Conv module is also used as the input of the third size detection head; and the output of the sixth Concat-Conv module is used as the input of the fourth size detection head.
[0026] Furthermore, the Head network also includes four RepConv modules, which are reparameterized convolutional modules used to reparameterize the Head network. Specifically, the output of the third Concat-Conv module serves as the input to the first RepConv module, and the output of the first RepConv module serves as the input to the first size detection head; the output of the fourth Concat-Conv module serves as the input to the second RepConv module, and the output of the second RepConv module serves as the input to the second size detection head; the output of the fifth Concat-Conv module serves as the input to the third RepConv module, and the output of the third RepConv module serves as the input to the third size detection head; and the output of the sixth Concat-Conv module serves as the input to the fourth RepConv module, and the output of the fourth RepConv module serves as the input to the fourth size detection head.
[0027] Furthermore, the CBS combination module includes a fifth CBS module, a sixth CBS module, a seventh CBS module, and an eighth CBS module; the feature map input to the multi-size target detection model passes through the fifth CBS module, the sixth CBS module, the seventh CBS module, and the eighth CBS module in sequence;
[0028] The first CBS module is a 2D convolution with a stride of 1 and a kernel size of 1x1, outputting 64 feature maps; the second CBS module is a 2D convolution with a stride of 1 and a kernel size of 1x1, outputting 128 feature maps; the third CBS module is a 2D convolution with a stride of 1 and a kernel size of 1x1, outputting 256 feature maps; and the fourth CBS module is a 2D convolution with a stride of 1 and a kernel size of 1x1, outputting 5 feature maps. 12; The fifth CBS module is a 2D convolution with a stride of 1 and a kernel size of 3x3, and outputs 32 feature maps; The sixth CBS module is a 2D convolution with a stride of 2 and a kernel size of 3x3, and outputs 64 feature maps; The seventh CBS module is a 2D convolution with a stride of 1 and a kernel size of 3x3, and outputs 64 feature maps; The eighth CBS module is a 2D convolution with a stride of 2 and a kernel size of 3x3, and outputs 128 feature maps.
[0029] As a second aspect of the present invention, a multi-size target detection system based on an improved YOLOv7 is provided, comprising:
[0030] A construction module is used to build a multi-size target detection model based on YOLOv7 improvement; wherein, the multi-size target detection model includes a Backbone network, a Neck network, and a Head network; the Backbone network is used to perform four feature extractions on the feature map input to the multi-size target detection model; the Neck network is used to fuse the features extracted by the Backbone network in four steps to form four fusion branches, and the four fusion branches are input into the Head network to detect four targets of different sizes; the Head network outputs the detection results of four targets of different sizes.
[0031] The training module is used to train the multi-size target detection model;
[0032] The detection module is used to input the image to be detected into the multi-size target detection model after training, so that the multi-size target detection model outputs the target in the image to be detected that meets the size requirement;
[0033] The Backbone network comprises, in sequence, a CBS combining module, a first SIMAM combining module, a second SIMAM combining module, a third SIMAM combining module, and a fourth SIMAM combining module;
[0034] The first SIMAM combining module includes an ELAN module and a SIMAM module for initial feature extraction. The features extracted by the first SIMAM combining module are then input into the second SIMAM combining module and the Neck network.
[0035] The second SIMAM combining module includes an MPConv module, an ELAN module, and a SIMAM module for a second feature extraction. The features extracted by the second SIMAM combining module are input to the third SIMAM combining module and the Neck network, respectively.
[0036] The third SIMAM combining module includes an MPConv module, an ELAN module, and a SIMAM module for the third feature extraction. The features extracted by the third SIMAM combining module are respectively input into the fourth SIMAM combining module and the Neck network.
[0037] The fourth SIMAM combining module includes an MPConv module, an ELAN module, an SPPCSPC module, and a SIMAM module in sequence for extracting features for the fourth time and inputting the extracted features into the Neck network;
[0038] The CBS ensemble module includes four different CBS modules, which are used to change the size and number of feature maps; the ELAN module is an efficient layer aggregation network used for multi-scale feature extraction and fusion of images; the SIMAM module is used to incorporate a three-dimensional attention mechanism during feature extraction to improve the feature extraction capability of the multi-size object detection model network; the SIMAM modules in the four SIMAM ensemble modules all input the extracted features into the Neck network; the MPConv module is used for pooling the feature maps; and the SPPCSPC module is used to extract features after explicitation at different sizes.
[0039] As a third aspect of the present invention, an electronic device is provided, comprising:
[0040] One or more processors;
[0041] Storage device for storing one or more programs;
[0042] When the one or more programs are executed by the one or more processors, the one or more processors perform the method described in the first aspect above.
[0043] As a fourth aspect of the present invention, a computer-readable medium is provided having a computer program stored thereon, which, when executed by a processor, implements the method described in the first aspect above.
[0044] The beneficial effects of this invention are:
[0045] This invention improves the Backbone, Neck, and Head networks of the YOLOv7 model to address the characteristics of small and densely packed targets. The Backbone network adds feature extraction for small-sized targets, resulting in four scale feature maps. Furthermore, a three-dimensional attention mechanism, SimAM, is incorporated into the feature extraction process at all four scales to enhance the network's feature extraction capabilities. Output branches are added to the Neck and Head networks, thus solving the technical problem of poor detection performance of the YOLOv7 detection network for small targets with limited pixel information in existing technologies. Attached Figure Description
[0046] Figure 1 The diagram illustrates the steps of a multi-size target detection method based on an improved YOLOv7.
[0047] Figure 2 A schematic diagram of the structure of a multi-size target detection model based on YOLOv7 is shown.
[0048] Figure 3 for Figure 2 CBS module structure diagram.
[0049] Figure 4 for Figure 2 Structure diagram of the ELAN module.
[0050] Figure 5 for Figure 2 MPConv module structure diagram.
[0051] Figure 6 for Figure 2 SPC module structure diagram.
[0052] Figure 7 for Figure 2 Structure diagram of the Concat-Conv module.
[0053] Figure 8 A block diagram of a multi-size target detection system based on an improved YOLOv7 is shown schematically.
[0054] Figure 9 A block diagram of an electronic device is shown schematically.
[0055] Figure 10 A block diagram of a computer-readable medium is shown schematically. Detailed Implementation
[0056] Exemplary embodiments will now be described more fully with reference to the accompanying drawings. However, these exemplary embodiments can be implemented in many forms and should not be construed as limited to the embodiments set forth herein; rather, they are provided so that this application will be thorough and complete, and will fully convey the concept of the exemplary embodiments to those skilled in the art. The same reference numerals in the drawings denote the same or similar parts, and therefore repeated descriptions of them will be omitted.
[0057] Furthermore, the described features, structures, or characteristics can be combined in any suitable manner in one or more embodiments. Numerous specific details are provided in the following description to give a thorough understanding of embodiments of this application. However, those skilled in the art will recognize that the technical solutions of this application can be practiced without one or more of the specific details, or other methods, components, apparatuses, steps, etc., can be employed. In other instances, well-known methods, apparatuses, implementations, or operations are not shown or described in detail to avoid obscuring various aspects of this application.
[0058] The block diagrams shown in the accompanying drawings are merely functional entities and do not necessarily correspond to physically independent entities. That is, these functional entities can be implemented in software, in one or more hardware modules or integrated circuits, or in different network and / or processor devices and / or microcontroller devices.
[0059] The flowcharts shown in the accompanying drawings are merely illustrative and do not necessarily include all content and operations / steps, nor do they necessarily have to be performed in the described order. For example, some operations / steps can be broken down, while others can be combined or partially combined; therefore, the actual execution order may change depending on the specific circumstances.
[0060] It should be understood that although the terms first, second, third, etc., may be used herein to describe various components, these components should not be limited by these terms. These terms are used to distinguish one component from another. Therefore, the first component discussed below may be referred to as the second component without departing from the teachings of this application. As used herein, the term "and / or" includes all combinations of any one and more of the associated listed items.
[0061] Those skilled in the art will understand that the accompanying drawings are merely schematic diagrams of exemplary embodiments, and the modules or processes in the drawings are not necessarily essential for implementing this application, and therefore cannot be used to limit the scope of protection of this application.
[0062] According to a first specific embodiment of the present invention, such as Figure 1 As shown, this invention provides a multi-size target detection method based on YOLOv7, comprising the following steps:
[0063] S11, Construct a multi-size target detection model based on YOLOv7 improvement.
[0064] Figure 2 A constellation configuration diagram of a multi-size target detection model based on an improved YOLOv7 is schematically shown. (See diagram for example.) Figure 2 As shown, the multi-size target detection model includes a Backbone network, a Neck network, and a Head network. The Backbone network performs four feature extractions on the feature map input to the multi-size target detection model. The Neck network fuses the features extracted by the Backbone network to form four fusion branches, and inputs these four fusion branches into the Head network to detect four targets of different sizes. The Head network outputs the detection results for the four targets of different sizes.
[0065] Please refer to Figure 2 and Figure 3 , Figure 3 for Figure 2 CBS module structure diagram. (See diagram below.) Figure 2 and Figure 3As shown, the CBS combination module includes four different CBS modules. These modules are used to change the size and number of feature maps. Multiple CBS modules can be stacked or combined with other modules to achieve features extraction, feature fusion, and other purposes. Each CBS module consists of a two-dimensional convolutional layer (Conv), a batch normalization layer (BN), and an activation function layer (SiLU) connected sequentially.
[0066] like Figure 2 As shown, the CBS combination module includes a fifth CBS module, a sixth CBS module, a seventh CBS module, and an eighth CBS module connected in sequence. Specifically, the fifth CBS module is a 2D convolution with a stride of 1 and a kernel size of 3x3, outputting 32 feature maps; the sixth CBS module is a 2D convolution with a stride of 2 and a kernel size of 3x3, outputting 64 feature maps; the seventh CBS module is a 2D convolution with a stride of 1 and a kernel size of 3x3, outputting 64 feature maps; and the eighth CBS module is a 2D convolution with a stride of 2 and a kernel size of 3x3, outputting 128 feature maps.
[0067] Assume the image size input to the multi-size object detection model is H*W*C, where H represents length, W represents width, and C represents the number of channels. For example... Figure 2 As shown, if the input image size is 640*640*3, the feature map size after passing through the CBS combination module becomes 160*160*128.
[0068] Continue to refer to Figure 2 The feature map after passing through the CBS combining module enters the first SIMAM combining module, which performs the first feature extraction on the input feature map. The features extracted by the first SIMAM combining module are then input into the second SIMAM combining module and the Neck network. Figure 2 As shown, the first SIMAM combination module includes an ELAN module and a SIMAM module in sequence.
[0069] The ELAN module is a high-efficiency layer aggregation network whose function is to extract and fuse multi-scale features from images. Please refer to the following... Figure 4 , Figure 4 for Figure 2 The ELAN module structure diagram. The ELAN module aggregates features from four different levels to better capture multi-scale information. The ELAN module includes four branches, such as... Figure 4As shown, branches 1 and 4 each undergo one CBS module operation, branch 2 undergoes five consecutive CBS module operations, and branch 3 undergoes three consecutive CBS module operations. The outputs of these four branches are then processed by the Concat module, which fuses the features of these four branch outputs along the channel dimension. Finally, another CBS module is used, thus completing the ELAN module operation. Figure 2 As shown, the improved multi-size target detection model based on YOLOv7 uses four ELAN modules, and the parameters of the CBS module in each ELAN module are different.
[0070] like Figure 2 As shown, the first SIMAM combination also includes a SIMAM module. The feature map after passing through the CBS combination module passes through the ELAN module and then enters the SIMAM module. The SIMAM module is used to incorporate a three-dimensional attention mechanism during feature extraction to improve the feature extraction capability of the multi-size object detection model network. The SIMAM module in all four SIMAM combination modules inputs the extracted features into the Neck network.
[0071] Inspired by neuroscience, the SIMAM module posits that neurons containing more information often behave differently from surrounding neurons. Therefore, an energy function, e, is proposed to measure the importance of each neuron. A smaller e value indicates that the neuron contains more important information, and its weight should be higher.
[0072] According to research in visual neuroscience, the most information-rich neurons are typically those that exhibit activation patterns significantly different from surrounding neurons. Furthermore, an active neuron can inhibit the activity of surrounding neurons; this phenomenon is known as spatial inhibition. To calculate the importance of each neuron, the following energy function is defined:
[0073]
[0074] Among them, e t Represents the neuron's energy function. and It is t and x i linear transformation, w t and b t These refer to the weights and biases during the transformation of a specific neuron. t and x i These refer to the target neuron and other neurons in a single channel of the input feature X, respectively. i is the index in the spatial dimension, and M is the number of neurons in one channel. y represents a constant value. t and y oThese are two distinct constant values used to simplify calculations. By minimizing this energy function, the linear separability between the target neuron t and other neurons in the same channel can be found. To simplify calculations, a regularization term λ is introduced, and the final energy function is as follows:
[0075]
[0076] Theoretically, for each channel, there are M energy functions that need to be solved. However, by making some assumptions, the mean and variance of all neurons in the channel can be calculated and reused, thus avoiding the computational cost of iteratively calculating the mean and variance for each location. Therefore, the minimum energy can be calculated using the following formula:
[0077]
[0078] in, and These are the mean and variance calculated across all neurons in the channel, respectively. This represents the minimum value of the energy function. The lower the energy value, the greater the difference between neuron t and surrounding neurons, and the higher its importance. According to the definition of the attention mechanism, a SIMAM module can be represented by the following formula:
[0079]
[0080] in, X is the output of the SIMAM module, X is the input of the SIMAM module, and E is the output of all modules. Grouping along the channel and spatial dimensions, sigmoid is used to limit excessively large values in e.
[0081] like Figure 2 As shown, if the input image size is 640*640*3, the feature map size after passing through the CBS combining module becomes 160*160*128, and the feature map size after passing through the SIMAM module in the first SIMAM combining module becomes 160*160*256. The feature map after passing through the SIMAM module in the first SIMAM combining module has two output directions, such as... Figure 2 As shown, one input of the feature map is to the Neck network, and the other input is to the second SIMAM combination.
[0082] Continue to refer to Figure 2 The second SIMAM compositing module sequentially includes an MPConv module, an ELAN module, and a SIMAM module for a second feature extraction. The features extracted in the second SIMAM compositing module are then input into the third SIMAM compositing module and the Neck network, respectively. Figure 2As shown, compared to the first SIMAM combination module, the second SIMAM combination module has an additional MPConv module.
[0083] The MPConv module is used for pooling feature maps. Please refer to [reference needed]. Figure 5 , Figure 5 for Figure 2 The structure diagram of the MPConv module. (See attached diagram.) Figure 5 As shown, the MPConv module consists of two branches: the first branch first passes through a max pooling layer Maxpoolk2 (k2 represents the pooling kernel size of (2*2), with a stride of 2), and then through a 1*1 convolutional module to adjust the output feature dimension; the second branch first passes through a 1*1 convolutional module to adjust the feature dimension, and then through a 3*3 convolutional module with a stride of 2 to achieve downsampling; finally, the results of the first branch and the second branch are concatenated to obtain the final output of the MPConv module.
[0084] The features extracted by the first SIMAM assembling module will sequentially pass through the MPConv module, ELAN module, and SIMAM module in the second SIMAM assembling module. Since the structures of the ELAN and SIMAM modules have already been described in the relevant sections of the first SIMAM assembling module, they will not be repeated here for the sake of brevity.
[0085] like Figure 2 As shown, if the input image size is 640*640*3, the feature map size after passing through the CBS combining module becomes 160*160*128, the feature map size after passing through the SIMAM module in the first SIMAM combining module becomes 160*160*256, and the feature map size after passing through the SIMAM module in the second SIMAM combining module becomes 80*80*512. The feature map after passing through the SIMAM module in the second SIMAM combining module has two output directions, such as... Figure 2 As shown, one input of the feature map is to the Neck network, and the other input is to the third SIMAM combination.
[0086] Continue to refer to Figure 2 The third SIMAM compositing module includes the MPConv module, the ELAN module, and the SIMAM module in sequence for the third feature extraction. The features extracted by the third SIMAM compositing module are input into the fourth SIMAM compositing module and the Neck network, respectively.
[0087] The features extracted in the second SIMAM combination module will sequentially pass through the MPConv module, ELAN module, and SIMAM module in the third SIMAM combination module. Since the structures of the MPConv module, ELAN module, and SIMAM module have already been described in the relevant sections of the first and second SIMAM combination modules, they will not be repeated here for the sake of brevity.
[0088] like Figure 2 As shown, if the input image size is 640*640*3, the feature map size after passing through the CBS combination module becomes 160*160*128. After passing through the SIMAM module in the first SIMAM combination, the feature map size becomes 160*160*256. After passing through the SIMAM module in the second SIMAM combination, the feature map size becomes 80*80*512. After passing through the SIMAM module in the third SIMAM combination, the feature map size becomes 40*40*1024. The feature map after passing through the SIMAM module in the third SIMAM combination has two output directions, such as... Figure 2 As shown, one input of the feature map is to the Neck network, and the other input is to the fourth SIMAM combination.
[0089] Continue to refer to Figure 2 The fourth SIMAM compositing module, consisting of the MPConv module, ELAN module, SPPCSPC module, and SIMAM module, is used for the fourth feature extraction and inputs the extracted features into the Neck network. The features extracted in the third SIMAM compositing module are then processed sequentially through the MPConv module, ELAN module, SPPCSPC module, and SIMAM module in the fourth SIMAM compositing module. Since the structures of the MPConv module, ELAN module, and SIMAM module have already been described in the relevant sections of the first and second SIMAM compositing modules, they will not be repeated here for the sake of brevity.
[0090] The SPPCSPC module is used to extract features at different sizes after visualization. Please refer to [reference needed]. Figure 6 , Figure 6 for Figure 2 The structure diagram of the SPPC module in the Chinese language. (See diagram below.) Figure 6As shown, the SPPCSPC module consists of 7 CBS modules (each CBS module outputs 512 feature maps, but the size of the 2D convolutional kernel and the stride are different) and 3 max pooling layers (Maxpool k5, Maxpool k9, and Maxpool k13). The stride of the 3 max pooling layers is 1. The kernel size of max pooling layer Maxpool k5 is 5*5, the kernel size of max pooling layer Maxpool k9 is 9*9, and the kernel size of max pooling layer Maxpool k13 is 13*13.
[0091] like Figure 6 As shown, the SPPCSPC module divides the input into two branches. One branch performs feature extraction, which is then processed through a feature pyramid and max pooled on features of different sizes. The extracted feature information is then concatenated with the feature map that has not undergone feature pyramid pooling (i.e., the other branch). This operation enables the network to extract features of different sizes without losing information from the original feature map, thereby improving detection accuracy.
[0092] like Figure 2 As shown, if the input image size is 640*640*3, the feature map size after passing through the CBS combination module becomes 160*160*128, the feature map size after passing through the SIMAM module in the first SIMAM combination is 160*160*256, the feature map size after passing through the SIMAM module in the second SIMAM combination is 80*80*512, the feature map size after passing through the SIMAM module in the third SIMAM combination is 40*40*1024, and the feature map size after passing through the SIMAM module in the fourth SIMAM combination is 20*20*512. The feature map after passing through the SIMAM module in the fourth SIMAM combination is input into the Neck network.
[0093] Continue to refer to Figure 2 The four feature maps P1-P4 output by the BackBone network are respectively fed into the top-down fusion layer of the Neck network to obtain four fused feature results, which are then input into the Head network. For example... Figure 2 As shown, the Neck network includes 2 first CBS modules, 2 second CBS modules, 2 third CBS modules, 1 fourth CBS module, 3 upsampling modules, 6 Concat modules, 6 Concat-Conv modules, and 3 MPConv modules.
[0094] The first, second, third, and fourth CBS modules are four different CBS modules. The first CBS module is a 2D convolution with a stride of 1 and a kernel size of 1x1, and outputs 64 feature maps; the second CBS module is a 2D convolution with a stride of 1 and a kernel size of 1x1, and outputs 128 feature maps; the third CBS module is a 2D convolution with a stride of 1 and a kernel size of 1x1, and outputs 256 feature maps; the fourth CBS module is a 2D convolution with a stride of 1 and a kernel size of 1x1, and outputs 512 feature maps.
[0095] The Concat module is used for feature fusion along the channel dimension. The Concat-Conv module is used for multi-scale feature extraction and fusion of images. Please refer to [link / reference]. Figure 7 , Figure 7 for Figure 2 The structure diagram of the Concat-Conv module. (See diagram below.) Figure 7 As shown, the Concat-Conv module aggregates features from six different levels to better capture multi-scale information. The Concat-Conv module consists of six branches. Branches 1 and 6 each undergo one CBS module operation, branch 2 undergoes five consecutive CBS module operations, branch 3 undergoes four consecutive CBS module operations, branch 4 undergoes three consecutive CBS module operations, and branch 5 undergoes two consecutive CBS module operations. The outputs of these six branches are then processed through the Concat module, which fuses the features from these six branches along the channel dimension. Finally, it passes through another CBS module, thus completing the Concat-Conv module operation.
[0096] like Figure 2As shown, the Head network includes a first-size detection head, a second-size detection head, a third-size detection head, and a fourth-size detection head; wherein, the order is first size > second size > third size > fourth size. Features extracted by the fourth SIMAM compositing module are sequentially processed by the fourth CBS module, the first third CBS module, the first upsampling module, the first Concat module, the first Concat-Conv module, the second CBS module, the second upsampling module, the second Concat module, the second Concat-Conv module, the first CBS module, the third upsampling module, the third Concat module, and the third Concat-Conv module; features extracted by the third SIMAM compositing module are processed by the second third CBS module and the first Concat module; features extracted by the second SIMAM compositing module are processed by the second second CBS module and the second Concat module; features extracted by the first SIMAM compositing module are processed by the second first CBS module and the third Concat module; the output of the third Concat-Conv module serves as the input to the first-size detection head.
[0097] The output of the third Concat-Conv module is then passed sequentially through the first MPConv module, the fourth Concat module, the fourth Concat-Conv module, the second MPConv module, the fifth Concat module, the fifth Concat-Conv module, the third MPConv module, the sixth Concat module, and the sixth Concat-Conv module; the output of the second Concat-Conv module is also used as the input of the fourth Concat module; the output of the first Concat-Conv module is also used as the input of the fifth Concat module; and the output of the fourth CBS module is also used as the input of the sixth Concat module.
[0098] The output of the fourth Concat-Conv module is also used as the input of the second size detection head; the output of the fifth Concat-Conv module is also used as the input of the third size detection head; and the output of the sixth Concat-Conv module is used as the input of the fourth size detection head.
[0099] The Head network also includes four RepConv modules. RepConv modules are reparameterized convolutional modules, designed to reparameterize the network, reducing computational complexity and improving performance. Specifically, the output of the third Concat-Conv module serves as the input to the first RepConv module, and the output of the first RepConv module serves as the input to the first-size detector head; the output of the fourth Concat-Conv module serves as the input to the second RepConv module, and the output of the second RepConv module serves as the input to the second-size detector head; the output of the fifth Concat-Conv module serves as the input to the third RepConv module, and the output of the third RepConv module serves as the input to the third-size detector head; and the output of the sixth Concat-Conv module serves as the input to the fourth RepConv module, and the output of the fourth RepConv module serves as the input to the fourth-size detector head.
[0100] Optionally, the loss function of the YOLOv7-based improved multi-size object detection model is a hybrid bounding box regression loss function based on CIOU loss function and normalized Gaussian Wasserstein distance.
[0101] The existing YOLOv7 uses CIOU as the bounding box regression loss function. However, CIOU alone is too sensitive to small changes in the pixel position of the target, which can cause the model's performance in detecting small targets to drop rapidly. In contrast, the Normalized Wasserstein Distance (NWD) is smoother to changes in positional offset, and NWD can measure the similarity between non-overlapping or overlapping small bounding boxes.
[0102] Modeling the bounding box as a Gaussian distribution is as follows: Determining a bounding box requires knowing the coordinates of its center point (c). x ,c y ), width (w), and height (h). Any horizontal bounding box R = (c x ,c y The equation of its inscribed ellipse (w, h) can be expressed as:
[0103]
[0104] The probability density function of the two-dimensional Gaussian distribution is as follows:
[0105]
[0106] Where x is the coordinate of a two-dimensional Gaussian distribution, Σ is the covariance matrix, and μ is the mean vector. When the bounding box R is inscribed in an ellipse, it is the density profile of a two-dimensional Gaussian distribution. Therefore, the bounding box R = (c x ,c y The distribution (w,h) can be modeled as a Gaussian distribution. Therefore, the similarity between two bounding boxes can be converted into the distribution distance between the Gaussian distributions corresponding to the two bounding boxes. The normalized Wasserstein distance is used as the distance between the two Gaussian distributions. In actual detection tasks, the Gaussian distributions corresponding to the predicted box P and the ground truth box T are P ~ N(μ P ,∑ P ),T~N(μ T ,∑ T The Wasserstein distance between these two Gaussian distributions is defined as follows:
[0107]
[0108] When the covariance matrix satisfies the transformation: ∑ P ∑ T =∑ T Σ P When, P = (c xP ,c yP ,w P ,h p ), T=(c xT ,c yT ,w T ,h T Substituting the values, we get the following formula:
[0109]
[0110] Because the Wasserstein distance is a distance metric that cannot be directly used to measure the similarity between bounding boxes, it can cause the loss function to have difficulty converging. Therefore, the Wasserstein distance is normalized:
[0111]
[0112] Where C is a constant closely related to the training dataset; for example, in the apple detection task, an empirical value of 12.8 can be used. After obtaining the NWD, multiplying it by the weight factor λ and then adding it to CIOU yields the new bounding box regression loss function:
[0113] lbox=λ*NWD+(1-λ)CIOU
[0114] If the proportion of small objectives in the task is relatively large, the weight λ of NWD can be increased accordingly. For example, λ can be 0.5 for the Apple detection task.
[0115] like Figure 2As shown, if the input image size is 640*640*3, the feature map size after passing through the CBS combination module becomes 160*160*128. After passing through the SIMAM module in the first SIMAM combination, the feature map size becomes 160*160*256. After passing through the SIMAM module in the second SIMAM combination, the feature map size becomes 80*80*512. After passing through the SIMAM module in the third SIMAM combination, the feature map size becomes 40*40*1024. After passing through the SIMAM module in the fourth SIMAM combination, the feature map size becomes 20*20*512. This feature map after the fourth SIMAM combination is input into the Neck network. The Neck network fuses the top and bottom layer features from top to bottom, obtaining four sets of fused feature results, which are then input into the Head network. Specifically, the Neck network inputs a feature map of size 160*160*64 to the first-size detection head, and the output feature map of the first-size detection head is 160*160; the Neck network inputs a feature map of size 80*80*128 to the second-size detection head, and the output feature map of the second-size detection head is 80*80; the Neck network inputs a feature map of size 40*40*256 to the third-size detection head, and the output feature map of the third-size detection head is 40*40; the Neck network inputs a feature map of size 20*20*512 to the fourth-size detection head, and the output feature map of the fourth-size detection head is 20*20.
[0116] After completing the construction of the multi-size target detection model based on YOLOv7, proceed to step S12.
[0117] S12, train the multi-size target detection model.
[0118] S13, input the image to be detected into the multi-size target detection model after training, so that the multi-size target detection model outputs the target in the image to be detected that meets the size requirement.
[0119] After constructing a multi-size object detection model based on an improved YOLOv7, a training set and a validation set of image data are established. The training set of image data is input into the multi-size object detection model based on the improved YOLOv7 for training, and the validation set is used to detect and output multi-size object detection results. The trained multi-size object detection model is then used to perform multi-size object detection on the image to be detected.
[0120] To verify the impact of each improvement on model performance, the original YOLOv7 was used as the baseline model, and the improved parts were added sequentially. Ablation experiments were conducted on the Apple (self-made Apple dataset) and Drone (public dataset) datasets, and the results are detailed in Table 1. Method A represents the incorporation of the SimAM attention mechanism in the feature extraction stage, Method B represents the addition of an extra small object detection head, and Method C represents the addition of NWD loss to the original bounding box loss of the network. Table 1 shows that the proposed methods all improve the model's detection capability, especially Method C, which improves the model's detection capability without increasing any network parameters. Therefore, the effectiveness of NWD loss for small object detection is fully demonstrated. The improved network shows a 1.61% improvement in mAP@0.5 on the Apple dataset and a 3.95% improvement in map@0.5 on the Drone dataset, demonstrating significant performance enhancements.
[0121] Table 1
[0122]
[0123] This application addresses the characteristics of small and densely packed targets by improving the Backbone, Head, and bounding box loss functions of the existing YOLOv7 model. The Backbone outputs feature maps at four scales, and a 3D attention mechanism, SimAM, is added to enhance the network's feature extraction capabilities. An additional small target detection head is added to the Head module to improve the algorithm's regression accuracy for small targets. A hybrid bounding box loss based on CIoU and Wasserstein distance is used to replace the original IoU-based bounding box loss, solving the technical problem of poor performance of the existing YOLOv7 detection network for detecting small targets with limited pixel information.
[0124] According to a second specific embodiment of the present invention, the present invention provides a multi-size target detection system based on YOLOv7, employing the method of the first specific embodiment, such as... Figure 8 As shown, the multi-size target detection system 400 based on the improved YOLOv7 includes:
[0125] Module 410 is used to construct a multi-size target detection model based on YOLOv7 improvement; wherein, the multi-size target detection model includes a Backbone network, a Neck network, and a Head network; the Backbone network is used to perform four feature extractions on the feature map input to the multi-size target detection model; the Neck network is used to fuse the features extracted by the Backbone network in four steps to form four fusion branches, and input the four fusion branches into the Head network to detect four targets of different sizes; the Head network outputs the detection results of four targets of different sizes.
[0126] Training module 420 is used to train the multi-size target detection model;
[0127] Detection module 430 is used to input the image to be detected into the multi-size target detection model after training, so that the multi-size target detection model outputs the target in the image to be detected that meets the size requirement;
[0128] The Backbone network comprises, in sequence, a CBS combining module, a first SIMAM combining module, a second SIMAM combining module, a third SIMAM combining module, and a fourth SIMAM combining module;
[0129] The first SIMAM combining module includes an ELAN module and a SIMAM module for initial feature extraction. The features extracted by the first SIMAM combining module are then input into the second SIMAM combining module and the Neck network.
[0130] The second SIMAM combining module includes an MPConv module, an ELAN module, and a SIMAM module for a second feature extraction. The features extracted by the second SIMAM combining module are input to the third SIMAM combining module and the Neck network, respectively.
[0131] The third SIMAM combining module includes an MPConv module, an ELAN module, and a SIMAM module for the third feature extraction. The features extracted by the third SIMAM combining module are respectively input into the fourth SIMAM combining module and the Neck network.
[0132] The fourth SIMAM combining module includes an MPConv module, an ELAN module, an SPPCSPC module, and a SIMAM module in sequence for extracting features for the fourth time and inputting the extracted features into the Neck network;
[0133] The CBS ensemble module includes four different CBS modules, which are used to change the size and number of feature maps; the ELAN module is an efficient layer aggregation network used for multi-scale feature extraction and fusion of images; the SIMAM module is used to incorporate a three-dimensional attention mechanism during feature extraction to improve the feature extraction capability of the multi-size object detection model network; the SIMAM modules in the four SIMAM ensemble modules all input the extracted features into the Neck network; the MPConv module is used for pooling the feature maps; and the SPPCSPC module is used to extract features after explicitation at different sizes.
[0134] According to a third specific embodiment of the present invention, the present invention provides an electronic device, such as... Figure 9 As shown, Figure 9 This is a block diagram illustrating an electronic device according to an exemplary embodiment.
[0135] The following reference Figure 9 To describe an electronic device 200 according to this embodiment of the present application. Figure 9 The electronic device 200 shown is merely an example and should not impose any limitations on the functionality and scope of use of the embodiments of this application.
[0136] like Figure 9 As shown, the electronic device 200 is presented in the form of a general-purpose computing device. The components of the electronic device 200 may include, but are not limited to: at least one processing unit 210, at least one storage unit 220, a bus 230 connecting different system components (including storage unit 220 and processing unit 210), a display unit 240, etc.
[0137] The storage unit stores program code that can be executed by the processing unit 210, causing the processing unit 210 to perform the steps described in this specification according to various exemplary embodiments of this application. For example, the processing unit 210 can perform actions such as... Figure 1 The steps are shown in the figure.
[0138] The storage unit 220 may include a readable medium in the form of a volatile storage unit, such as a random access memory unit (RAM) 2201 and / or a cache storage unit 2202, and may further include a read-only memory unit (ROM) 2203.
[0139] The storage unit 220 may also include a program / utility 2204 having a set (at least one) program module 2205, such program module 2205 including but not limited to: an operating system, one or more application programs, other program modules and program data, each or some combination of these examples may include an implementation of a network environment.
[0140] Bus 230 can represent one or more of several types of bus structures, including a memory cell bus or memory cell controller, a peripheral bus, a graphics acceleration port, a processing unit, or a local bus using any of the various bus structures.
[0141] Electronic device 200 can also communicate with one or more external devices 200' (e.g., keyboard, pointing device, Bluetooth device, etc.), enabling users to communicate with devices that interact with electronic device 200, and / or any device (e.g., router, modem, etc.) that allows electronic device 200 to communicate with one or more other computing devices. This communication can be performed via input / output (I / O) interface 250. Furthermore, electronic device 200 can also communicate with one or more networks (e.g., local area network (LAN), wide area network (WAN), and / or public networks, such as the Internet) via network adapter 260. Network adapter 260 can communicate with other modules of electronic device 200 via bus 230. It should be understood that, although not shown in the figures, other hardware and / or software modules can be used in conjunction with electronic device 200, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
[0142] Through the above description of the embodiments, those skilled in the art will readily understand that the exemplary embodiments described herein can be implemented by software or by combining software with necessary hardware.
[0143] Therefore, according to a fourth specific embodiment of the present invention, the present invention provides a computer-readable medium. For example... Figure 10 As shown, the technical solution according to the embodiments of the present invention can be embodied in the form of a software product. The software product can be stored in a non-volatile storage medium (such as a CD-ROM, USB flash drive, mobile hard drive, etc.) or on a network, and includes several instructions to cause a computing device (such as a personal computer, server, or network device, etc.) to execute the above-described method according to the embodiments of the present invention.
[0144] The software product may employ any combination of one or more readable media. A readable medium may be a readable signal medium or a readable storage medium. A readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of readable storage media (a non-exhaustive list) include: electrical connections with one or more wires, portable disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.
[0145] The computer-readable storage medium may include data signals propagated in baseband or as part of a carrier wave, carrying readable program code. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. The readable storage medium may also be any readable medium other than a readable storage medium, capable of transmitting, propagating, or transmitting programs for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the readable storage medium may be transmitted using any suitable medium, including but not limited to wireless, wired, optical fiber, RF, etc., or any suitable combination thereof.
[0146] Program code for performing the operations of this invention can be written in any combination of one or more programming languages, including object-oriented programming languages such as Java and C++, and conventional procedural programming languages such as C or similar languages. The program code can execute entirely on the user's computing device, partially on the user's device, as a standalone software package, partially on the user's computing device and partially on a remote computing device, or entirely on a remote computing device or server. In cases involving remote computing devices, the remote computing device can be connected to the user's computing device via any type of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computing device (e.g., via the Internet using an Internet service provider).
[0147] The aforementioned computer-readable medium carries one or more programs, which, when executed by a device, cause the computer-readable medium to perform the functions of the first embodiment.
[0148] Those skilled in the art will understand that the above modules can be distributed in the device as described in the embodiments, or they can be modified accordingly and placed in one or more devices that are unique to this embodiment. The modules in the above embodiments can be combined into one module, or they can be further divided into multiple sub-modules.
[0149] Through the description of the above embodiments, those skilled in the art will readily understand that the exemplary embodiments described herein can be implemented by software or by combining software with necessary hardware. Therefore, the technical solutions of the embodiments of the present invention can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (such as a CD-ROM, USB flash drive, portable hard drive, etc.) or on a network, including several instructions to cause a computing device (such as a personal computer, server, mobile terminal, or network device, etc.) to execute the methods according to the embodiments of the present invention.
[0150] The above are merely preferred embodiments of the present invention and are not intended to limit the present invention. Various modifications and variations can be made to the present invention by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.
Claims
1. A multi-size target detection method based on YOLOv7 improvement, characterized in that, Includes the following steps: A multi-size target detection model based on an improved YOLOv7 is constructed. This model includes a Backbone network, a Neck network, and a Head network. The Backbone network performs four feature extractions on the feature map input to the model. The Neck network fuses the features extracted by the Backbone network to form four fusion branches, which are then input into the Head network to detect four targets of different sizes. The Head network outputs the detection results for the four targets of different sizes. Train the multi-size target detection model; The image to be detected is input into the multi-size target detection model after training, so that the multi-size target detection model outputs the target in the image to be detected that meets the size requirement; The Backbone network comprises, in sequence, a CBS combining module, a first SIMAM combining module, a second SIMAM combining module, a third SIMAM combining module, and a fourth SIMAM combining module; The first SIMAM combining module includes an ELAN module and a SIMAM module for initial feature extraction. The features extracted by the first SIMAM combining module are then input into the second SIMAM combining module and the Neck network. The second SIMAM combining module includes an MPConv module, an ELAN module, and a SIMAM module for a second feature extraction. The features extracted by the second SIMAM combining module are input to the third SIMAM combining module and the Neck network, respectively. The third SIMAM combining module includes an MPConv module, an ELAN module, and a SIMAM module for the third feature extraction. The features extracted by the third SIMAM combining module are respectively input into the fourth SIMAM combining module and the Neck network. The fourth SIMAM combining module includes an MPConv module, an ELAN module, an SPPCSPC module, and a SIMAM module in sequence for extracting features for the fourth time and inputting the extracted features into the Neck network; The CBS ensemble module includes four different CBS modules, which are used to change the size and number of feature maps; the ELAN module is an efficient layer aggregation network used for multi-scale feature extraction and fusion of images; the SIMAM module is used to incorporate a three-dimensional attention mechanism during feature extraction to improve the feature extraction capability of the multi-size object detection model network; the SIMAM modules in the four SIMAM ensemble modules all input the extracted features into the Neck network; the MPConv module is used for pooling the feature maps; and the SPPCSPC module is used to extract features after explicitation at different sizes.
2. The multi-size target detection method based on YOLOv7 improvement according to claim 1, characterized in that, The loss function of the multi-size target detection model is a hybrid bounding box regression loss function based on CIOU loss function and normalized Gaussian Wasserstein distance.
3. The multi-size target detection method based on YOLOv7 improvement according to claim 2, characterized in that, The expression for the hybrid bounding box regression loss function (lbox) is: lbox=λ*NWD+(1-λ)CIOU Where λ is the weighting factor and NWD is the normalized Gaussian Wasserstein distance.
4. The multi-size target detection method based on YOLOv7 improvement according to claim 1, characterized in that, The Neck network includes 2 first CBS modules, 2 second CBS modules, 2 third CBS modules, 1 fourth CBS module, 3 upsampling modules, 6 Concat modules, 6 Concat-Conv modules, and 3 MPConv modules; Among them, the first CBS module, the second CBS module, the third CBS module, and the fourth CBS module are four different CBS modules; the Concat module is used to perform feature fusion in the channel dimension; The Concat-Conv module is used to extract and fuse multi-scale features from images.
5. The multi-size target detection method based on YOLOv7 improvement according to claim 4, characterized in that, The Head network includes a first-size detection head, a second-size detection head, a third-size detection head, and a fourth-size detection head; wherein, the first size > the second size > the third size > the fourth size; The features extracted by the fourth SIMAM combining module are sequentially processed by the fourth CBS module, the first third CBS module, the first upsampling module, the first Concat module, the first Concat-Conv module, the second CBS module, the second upsampling module, the second Concat module, and the second... The module consists of a Concat-Conv module, a first CBS module, a third upsampling module, a third Concat module, and a third Concat-Conv module; the features extracted by the third SIMAM compositing module are processed by the second third CBS module and the first Concat module; the features extracted by the second SIMAM compositing module are processed by the second second CBS module and the second Concat module; the features extracted by the first SIMAM compositing module are processed by the second first CBS module and the third Concat module; the third... The output of the Concat-Conv module is used as the input of the first size detection head; The output of the third Concat-Conv module is then passed through the first MPConv module and the fourth... The system consists of a Concat module, a fourth Concat-Conv module, a second MPConv module, a fifth Concat module, a fifth Concat-Conv module, a third MPConv module, a sixth Concat module, and a sixth Concat-Conv module. The output of the second Concat-Conv module also serves as the input of the fourth Concat module. The output of the first Concat-Conv module also serves as the input of the fifth Concat module. The output of the fourth CBS module also serves as the input of the sixth Concat module. The output of the fourth Concat-Conv module is also used as the input of the second size detection head; the output of the fifth Concat-Conv module is also used as the input of the third size detection head; and the output of the sixth Concat-Conv module is used as the input of the fourth size detection head.
6. The multi-size target detection method based on YOLOv7 improvement according to claim 5, characterized in that, The Head network further includes four RepConv modules, which are reparameterized convolutional modules used to reparameterize the Head network. Specifically, the output of the third Concat-Conv module serves as the input to the first RepConv module, and the output of the first RepConv module serves as the input to the first size detection head; the output of the fourth Concat-Conv module serves as the input to the second RepConv module, and the output of the second RepConv module serves as the input to the second size detection head; the output of the fifth Concat-Conv module serves as the input to the third RepConv module, and the output of the third RepConv module serves as the input to the third size detection head; and the output of the sixth Concat-Conv module serves as the input to the fourth RepConv module, and the output of the fourth RepConv module serves as the input to the fourth size detection head.
7. The multi-size target detection method based on YOLOv7 improvement according to claim 4, characterized in that, The CBS combination module includes a fifth CBS module, a sixth CBS module, a seventh CBS module, and an eighth CBS module; the feature map input to the multi-size target detection model passes through the fifth CBS module, the sixth CBS module, the seventh CBS module, and the eighth CBS module in sequence; The first CBS module is a 2D convolution with a stride of 1 and a kernel size of 1x1, outputting 64 feature maps; the second CBS module is a 2D convolution with a stride of 1 and a kernel size of 1x1, outputting 128 feature maps; the third CBS module is a 2D convolution with a stride of 1 and a kernel size of 1x1, outputting 256 feature maps; and the fourth CBS module is a 2D convolution with a stride of 1 and a kernel size of 1x1, outputting 5 feature maps. 12; The fifth CBS module is a 2D convolution with a stride of 1 and a kernel size of 3x3, and outputs 32 feature maps; The sixth CBS module is a 2D convolution with a stride of 2 and a kernel size of 3x3, and outputs 64 feature maps; The seventh CBS module is a 2D convolution with a stride of 1 and a kernel size of 3x3, and outputs 64 feature maps; The eighth CBS module is a 2D convolution with a stride of 2 and a kernel size of 3x3, and outputs 128 feature maps.
8. A multi-size target detection system based on an improved YOLOv7, characterized in that, include: A construction module is used to build a multi-size target detection model based on YOLOv7 improvement; wherein, the multi-size target detection model includes a Backbone network, a Neck network, and a Head network; the Backbone network is used to perform four feature extractions on the feature map input to the multi-size target detection model; the Neck network is used to fuse the features extracted by the Backbone network in four steps to form four fusion branches, and the four fusion branches are input into the Head network to detect four targets of different sizes; the Head network outputs the detection results of four targets of different sizes. The training module is used to train the multi-size target detection model; The detection module is used to input the image to be detected into the multi-size target detection model after training, so that the multi-size target detection model outputs the target in the image to be detected that meets the size requirement; The Backbone network comprises, in sequence, a CBS combining module, a first SIMAM combining module, a second SIMAM combining module, a third SIMAM combining module, and a fourth SIMAM combining module; The first SIMAM combining module includes an ELAN module and a SIMAM module for initial feature extraction. The features extracted by the first SIMAM combining module are then input into the second SIMAM combining module and the Neck network. The second SIMAM combining module includes an MPConv module, an ELAN module, and a SIMAM module for a second feature extraction. The features extracted by the second SIMAM combining module are input to the third SIMAM combining module and the Neck network, respectively. The third SIMAM combining module includes an MPConv module, an ELAN module, and a SIMAM module for the third feature extraction. The features extracted by the third SIMAM combining module are respectively input into the fourth SIMAM combining module and the Neck network. The fourth SIMAM combining module includes an MPConv module, an ELAN module, an SPPCSPC module, and a SIMAM module in sequence for extracting features for the fourth time and inputting the extracted features into the Neck network; The CBS ensemble module includes four different CBS modules, which are used to change the size and number of feature maps; the ELAN module is an efficient layer aggregation network used for multi-scale feature extraction and fusion of images; the SIMAM module is used to incorporate a three-dimensional attention mechanism during feature extraction to improve the feature extraction capability of the multi-size object detection model network; the SIMAM modules in the four SIMAM ensemble modules all input the extracted features into the Neck network; the MPConv module is used for pooling the feature maps; and the SPPCSPC module is used to extract features after explicitation at different sizes.
9. An electronic device, characterized in that, include: One or more processors; Storage device for storing one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the method as described in any one of claims 1-7.
10. A computer-readable medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the method as described in any one of claims 1-7.
Citation Information
Patent Citations
Target detection method based on improved YOLOv7
CN117315449A
Underwater target identification method based on three-dimensional attention enhancement YOLO model
CN117975250A